xref: /trunk/main/sw/source/ui/misc/outline.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 #ifdef SW_DLLIMPLEMENTATION
31 #undef SW_DLLIMPLEMENTATION
32 #endif
33 #include <hintids.hxx>
34 #include <tools/shl.hxx>
35 #ifndef _MENU_HXX //autogen
36 #include <vcl/menu.hxx>
37 #endif
38 #ifndef _MSGBOX_HXX //autogen
39 #include <vcl/msgbox.hxx>
40 #endif
41 #include <sfx2/tabdlg.hxx>
42 #include <editeng/brshitem.hxx>
43 #include <unotools/configmgr.hxx>
44 #include <SwStyleNameMapper.hxx>
45 
46 #ifndef _NUM_HXX //autogen
47 #define USE_NUMTABPAGES
48 #include <num.hxx>
49 #endif
50 #ifndef _VIEW_HXX
51 #include <view.hxx>
52 #endif
53 #ifndef _DOCSH_HXX
54 #include <docsh.hxx>
55 #endif
56 #include <uitool.hxx>
57 #include <errhdl.hxx>
58 #include <wrtsh.hxx>
59 #include <swmodule.hxx>
60 #include <fmtcol.hxx>
61 #include <outline.hxx>
62 #include <uinums.hxx>
63 #include <poolfmt.hxx>
64 #include <shellres.hxx>
65 #include <svl/style.hxx>
66 #include <charfmt.hxx>
67 #include <docstyle.hxx>
68 #include <viewopt.hxx>
69 #include <svtools/ctrlbox.hxx>
70 #ifndef _HELPID_H
71 #include <helpid.h>
72 #endif
73 #ifndef _GLOBALS_HRC
74 #include <globals.hrc>		// fuer Vorlagenname 'keins'
75 #endif
76 #ifndef _MISC_HRC
77 #include <misc.hrc>
78 #endif
79 #ifndef _OUTLINE_HRC
80 #include <outline.hrc>
81 #endif
82 #include <paratr.hxx>
83 
84 #include <unomid.h>
85 
86 #include <IDocumentOutlineNodes.hxx>
87 // --> OD 2008-04-14 #outlinelevel#
88 #include <app.hrc>
89 // <--
90 
91 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
92 #include <com/sun/star/accessibility/AccessibleRole.hpp>
93 #endif
94 
95 using namespace ::com::sun::star;
96 
97 /* -----------------------------31.01.01 10:23--------------------------------
98 
99  ---------------------------------------------------------------------------*/
100 
101 DBG_NAME(outlinehdl)
102 
103 /*---------------------------------------------------------------------
104 
105 ---------------------------------------------------------------------*/
106 
107 class SwNumNamesDlg: public ModalDialog
108 {
109     FixedLine    aFormFL;
110 	Edit         aFormEdit;
111 	ListBox      aFormBox;
112 	OKButton     aOKBtn;
113 	CancelButton aCancelBtn;
114 	HelpButton   aHelpBtn;
115 
116 	DECL_LINK( ModifyHdl, Edit * );
117 	DECL_LINK( SelectHdl, ListBox * );
118 	DECL_LINK( DoubleClickHdl, ListBox * );
119 
120 public:
121 	SwNumNamesDlg(Window *pParent);
122 	~SwNumNamesDlg();
123 	void SetUserNames(const String *pList[]);
124 	String GetName() const { return aFormEdit.GetText(); }
125 	sal_uInt16 GetCurEntryPos() const { return aFormBox.GetSelectEntryPos(); }
126 };
127 
128 /*------------------------------------------------------------------------
129  Beschreibung:  selektierten Eintrag merken
130 ------------------------------------------------------------------------*/
131 
132 
133 IMPL_LINK_INLINE_START( SwNumNamesDlg, SelectHdl, ListBox *, pBox )
134 {
135 	aFormEdit.SetText(pBox->GetSelectEntry());
136 	aFormEdit.SetSelection(Selection(0, SELECTION_MAX));
137 	return 0;
138 }
139 IMPL_LINK_INLINE_END( SwNumNamesDlg, SelectHdl, ListBox *, pBox )
140 
141 /*------------------------------------------------------------------------
142  Beschreibung:  Setzen der vom Benutzer vergebenen Namen
143  Parameter:     Liste der vom Benutzer vergebenen Namen;
144 				nicht vom Benutzer benannte Positionen sind 0.
145 ------------------------------------------------------------------------*/
146 
147 
148 void SwNumNamesDlg::SetUserNames(const String *pList[])
149 {
150 	sal_uInt16 nSelect = 0;
151 	for(sal_uInt16 i = 0; i < SwBaseNumRules::nMaxRules; ++i)
152 	{
153 		if(pList[i])
154 		{
155 			aFormBox.RemoveEntry(i);
156 			aFormBox.InsertEntry(*pList[i], i);
157 			if(i == nSelect && nSelect < SwBaseNumRules::nMaxRules)
158 				nSelect++;
159 		}
160 	}
161 	aFormBox.SelectEntryPos(nSelect);
162 	SelectHdl(&aFormBox);
163 }
164 /*------------------------------------------------------------------------
165  Beschreibung:  OK-Button freischalten, wenn Text im Edit steht.
166 ------------------------------------------------------------------------*/
167 
168 
169 IMPL_LINK_INLINE_START( SwNumNamesDlg, ModifyHdl, Edit *, pBox )
170 {
171 	aOKBtn.Enable(0 != pBox->GetText().Len());
172 	return 0;
173 }
174 IMPL_LINK_INLINE_END( SwNumNamesDlg, ModifyHdl, Edit *, pBox )
175 /*------------------------------------------------------------------------
176  Beschreibung:  DoubleClickHdl
177 ------------------------------------------------------------------------*/
178 
179 
180 IMPL_LINK_INLINE_START( SwNumNamesDlg, DoubleClickHdl, ListBox *, EMPTYARG )
181 {
182 	EndDialog(RET_OK);
183 	return 0;
184 }
185 IMPL_LINK_INLINE_END( SwNumNamesDlg, DoubleClickHdl, ListBox *, EMPTYARG )
186 
187 /*--------------------------------------------------
188 
189 --------------------------------------------------*/
190 
191 SwNumNamesDlg::SwNumNamesDlg(Window *pParent)
192 	: ModalDialog(pParent, SW_RES(DLG_NUM_NAMES)),
193 	aFormFL(this, SW_RES(FL_FORM)),
194     aFormEdit(this, SW_RES(ED_FORM)),
195 	aFormBox(this, SW_RES(LB_FORM)),
196 	aOKBtn(this, SW_RES(BT_OK)),
197 	aCancelBtn(this, SW_RES(BT_CANCEL)),
198 	aHelpBtn(this, SW_RES(BT_HELP))
199 {
200 	FreeResource();
201 	aFormEdit.SetModifyHdl(LINK(this, SwNumNamesDlg, ModifyHdl));
202 	aFormBox.SetSelectHdl(LINK(this, SwNumNamesDlg, SelectHdl));
203 	aFormBox.SetDoubleClickHdl(LINK(this, SwNumNamesDlg, DoubleClickHdl));
204 	SelectHdl(&aFormBox);
205 }
206 
207 /*--------------------------------------------------
208 
209 --------------------------------------------------*/
210 
211 __EXPORT SwNumNamesDlg::~SwNumNamesDlg() {}
212 
213 
214 /* -----------------08.07.98 08:46-------------------
215  *
216  * --------------------------------------------------*/
217 sal_uInt16 lcl_BitToLevel(sal_uInt16 nActLevel)
218 {
219 	sal_uInt16 nTmp = nActLevel;
220 	sal_uInt16 nTmpLevel = 0;
221 	while( 0 != (nTmp >>= 1) )
222 		nTmpLevel++;
223 	return nTmpLevel;
224 }
225 
226 /* -----------------07.07.98 14:13-------------------
227  *
228  * --------------------------------------------------*/
229 sal_uInt16 SwOutlineTabDialog::nNumLevel = 1;
230 SwOutlineTabDialog::SwOutlineTabDialog(Window* pParent,
231 					const SfxItemSet* pSwItemSet,
232 					SwWrtShell &rSh) :
233 									//der UserString wird danach richtig gesetzt
234 		SfxTabDialog(pParent, SW_RES(DLG_TAB_OUTLINE), pSwItemSet, sal_False, &aEmptyStr),
235         aNullStr(C2S("____")),
236 		aFormMenu(SW_RES(MN_FORM)),
237         rWrtSh(rSh),
238 		pChapterNumRules(SW_MOD()->GetChapterNumRules()),
239         bModified(rWrtSh.IsModified())
240 {
241     // --> OD 2008-04-14 #outlinelevel#
242     SetText( SW_RES( STR_OUTLINE_NUMBERING ) );
243     // <--
244     PushButton* pUserButton = GetUserButton();
245     pUserButton->SetText(SW_RES(ST_FORM));
246     pUserButton->SetHelpId(HID_OUTLINE_FORM);
247     pUserButton->SetClickHdl(LINK(this, SwOutlineTabDialog, FormHdl));
248 	pUserButton->SetAccessibleRole( com::sun::star::accessibility::AccessibleRole::BUTTON_MENU );
249 
250 	FreeResource();
251 	pNumRule = new SwNumRule( *rSh.GetOutlineNumRule() );
252 	GetCancelButton().SetClickHdl(LINK(this, SwOutlineTabDialog, CancelHdl));
253 
254 	AddTabPage(TP_NUM_POSITION	 , &SwNumPositionTabPage::Create, 0);
255 	AddTabPage(TP_OUTLINE_NUM	 , &SwOutlineSettingsTabPage::Create, 0);
256 
257 	String sHeadline;
258 	sal_uInt16 i;
259 
260 	for( i = 0; i < MAXLEVEL; ++i )
261 	{
262 		// wurde die Vorlage noch nicht angelegt, dann ist sie noch an dieserPosition
263 		if( !rWrtSh.GetParaStyle( sHeadline =
264             SwStyleNameMapper::GetUIName( static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i),
265                                           sHeadline )) )
266 			aCollNames[i] = sHeadline;
267 	}
268 
269 	// Erfragen der Gliederungsebenen der Textvorlagen
270 	const sal_uInt16 nCount = rWrtSh.GetTxtFmtCollCount();
271 	for(i = 0; i < nCount; ++i )
272 	{
273 		SwTxtFmtColl &rTxtColl = rWrtSh.GetTxtFmtColl(i);
274 		if(!rTxtColl.IsDefault())
275 		{
276 			//sal_uInt8 nOutLevel = rTxtColl.GetOutlineLevel();	//<-#outline level, removed out by zhaojianwei
277 			//if(nOutLevel != NO_NUMBERING)
278 			//->added by zhaojianwei
279 			if(rTxtColl.IsAssignedToListLevelOfOutlineStyle())
280 			{
281 				int nOutLevel = rTxtColl.GetAssignedOutlineStyleLevel();
282 				aCollNames[ nOutLevel ] = rTxtColl.GetName();
283 			}
284 			//<-end
285 		}
286 	}
287 }
288 
289 /* -----------------07.07.98 14:13-------------------
290  *
291  * --------------------------------------------------*/
292 SwOutlineTabDialog::~SwOutlineTabDialog()
293 {
294 	delete pNumRule;
295 }
296 
297 /* -----------------07.07.98 14:13-------------------
298  *
299  * --------------------------------------------------*/
300 void 	SwOutlineTabDialog::PageCreated(sal_uInt16 nPageId, SfxTabPage& rPage)
301 {
302 	switch ( nPageId )
303 	{
304 		case TP_NUM_POSITION:
305                 ((SwNumPositionTabPage&)rPage).SetWrtShell(&rWrtSh);
306                 ((SwNumPositionTabPage&)rPage).SetOutlineTabDialog(this);
307 		break;
308 		case TP_OUTLINE_NUM:
309 				((SwOutlineSettingsTabPage&)rPage).SetWrtShell(&rWrtSh);
310 		break;
311 	}
312 }
313 /* -----------------07.07.98 14:19-------------------
314  *
315  * --------------------------------------------------*/
316 IMPL_LINK( SwOutlineTabDialog, CancelHdl, Button *, EMPTYARG )
317 {
318 	if (!bModified)
319 		rWrtSh.ResetModified();
320 	EndDialog(RET_CANCEL);
321 	return 0;
322 }
323 /* -----------------08.07.98 12:14-------------------
324  *
325  * --------------------------------------------------*/
326 IMPL_LINK( SwOutlineTabDialog, FormHdl, Button *, pBtn )
327 {
328 	//PopupMenu auffuellen
329 	for( sal_uInt16 i = 0; i < SwChapterNumRules::nMaxRules; ++i )
330 	{
331 		const SwNumRulesWithName *pRules = pChapterNumRules->GetRules(i);
332 		if( pRules )
333 			aFormMenu.SetItemText(i + MN_FORMBASE, pRules->GetName());
334 	}
335 	aFormMenu.SetSelectHdl(LINK(this, SwOutlineTabDialog, MenuSelectHdl));
336 	aFormMenu.Execute(pBtn, Rectangle(Point(0,0), pBtn->GetSizePixel()), POPUPMENU_EXECUTE_DOWN);
337 	return 0;
338 }
339 
340 /* -----------------08.07.98 12:14-------------------
341  *
342  * --------------------------------------------------*/
343 IMPL_LINK( SwOutlineTabDialog, MenuSelectHdl, Menu *, pMenu )
344 {
345 	sal_uInt8 nLevelNo = 0;
346 	switch(pMenu->GetCurItemId())
347 	{
348 		case MN_FORM1: nLevelNo = 1;	break;
349 		case MN_FORM2: nLevelNo = 2;	break;
350 		case MN_FORM3: nLevelNo = 3;	break;
351 		case MN_FORM4: nLevelNo = 4;	break;
352 		case MN_FORM5: nLevelNo = 5;	break;
353 		case MN_FORM6: nLevelNo = 6;	break;
354 		case MN_FORM7: nLevelNo = 7;	break;
355 		case MN_FORM8: nLevelNo = 8;	break;
356 		case MN_FORM9: nLevelNo = 9;	break;
357 
358 		case MN_SAVE:
359 		{
360 			SwNumNamesDlg *pDlg = new SwNumNamesDlg(this);
361 			const String *aStrArr[SwChapterNumRules::nMaxRules];
362 			for(sal_uInt16 i = 0; i < SwChapterNumRules::nMaxRules; ++i)
363 			{
364 				const SwNumRulesWithName *pRules = pChapterNumRules->GetRules(i);
365 				if(pRules)
366 					aStrArr[i] = &pRules->GetName();
367 				else
368 					aStrArr[i] = 0;
369 			}
370 			pDlg->SetUserNames(aStrArr);
371 			if(RET_OK == pDlg->Execute())
372 			{
373 				const String aName(pDlg->GetName());
374 				pChapterNumRules->ApplyNumRules( SwNumRulesWithName(
375 						*pNumRule, aName ), pDlg->GetCurEntryPos() );
376 				pMenu->SetItemText(
377 						pDlg->GetCurEntryPos() + MN_FORMBASE, aName);
378 			}
379 			delete pDlg;
380 			return 0;
381 
382 		}
383 
384 	}
385 	if( nLevelNo-- )
386 	{
387 		const SwNumRulesWithName *pRules = pChapterNumRules->GetRules( nLevelNo );
388 		if( pRules )
389 		{
390 			pRules->MakeNumRule( rWrtSh, *pNumRule );
391 			pNumRule->SetRuleType( OUTLINE_RULE );
392 		}
393 		else
394 			*pNumRule = *rWrtSh.GetOutlineNumRule();
395 	}
396 
397 	sal_uInt16	nPageId = GetCurPageId();
398 	SfxTabPage*	pPage = GetTabPage( nPageId );
399 	pPage->Reset(*GetOutputItemSet());
400 
401 	return 0;
402 }
403 /* -----------------07.07.98 14:19-------------------
404  *
405  * --------------------------------------------------*/
406 sal_uInt16 	SwOutlineTabDialog::GetLevel(const String &rFmtName) const
407 {
408 	for(sal_uInt16 i = 0; i < MAXLEVEL; ++i)
409 	{
410 		if(aCollNames[i] == rFmtName)
411 			return i;
412 	}
413 	return MAXLEVEL;//NO_NUMBERING;	//#outline level,zhaojianwei
414 
415 }
416 /* -----------------07.07.98 16:30-------------------
417  *
418  * --------------------------------------------------*/
419 short SwOutlineTabDialog::Ok()
420 {
421     SfxTabDialog::Ok();
422 	// bei allen erzeugten Vorlagen die Ebenen setzen, muss
423 	// geschehen, um evtl. aufgehobene Zuordnungen
424 	// auch wieder zu loeschen
425 
426     // --> OD 2006-12-11 #130443#
427     // encapsulate changes into a action to avoid effects on the current cursor
428     // position during the changes.
429     rWrtSh.StartAction();
430     // <--
431 
432     const SwNumRule * pOutlineRule = rWrtSh.GetOutlineNumRule();
433 
434 	sal_uInt16 i, nCount = rWrtSh.GetTxtFmtCollCount();
435 	for( i = 0; i < nCount; ++i )
436 	{
437 		SwTxtFmtColl &rTxtColl = rWrtSh.GetTxtFmtColl(i);
438 		if( !rTxtColl.IsDefault() )
439         {
440 			//rTxtColl.SetOutlineLevel( (sal_uInt8)GetLevel(rTxtColl.GetName()));//#outline level,removed by zhaojianwei
441 
442             const SfxPoolItem & rItem =
443                 rTxtColl.GetFmtAttr(RES_PARATR_NUMRULE, sal_False);
444 
445 			//if ((sal_uInt8)GetLevel(rTxtColl.GetName()) == NO_NUMBERING)	//#outline level,removed by zhaojianwei
446 			//{
447 			//	if (static_cast<const SwNumRuleItem &>(rItem).GetValue() ==
448 			//		pOutlineRule->GetName())
449 			//	{
450 			//		rTxtColl.ResetFmtAttr(RES_PARATR_NUMRULE);
451 			//	}
452 			//}
453 			//else
454 			//{
455 			//	if (static_cast<const SwNumRuleItem &>(rItem).GetValue() !=
456 			//		pOutlineRule->GetName())
457 			//	{
458 			//		SwNumRuleItem aItem(pOutlineRule->GetName());
459 			//		rTxtColl.SetFmtAttr(aItem);
460 			//	}
461 			//}
462            if ((sal_uInt8)GetLevel(rTxtColl.GetName()) == MAXLEVEL) //add by zhaojianwei
463             {
464 			    if(rTxtColl.IsAssignedToListLevelOfOutlineStyle())
465 				{
466 					rTxtColl.DeleteAssignmentToListLevelOfOutlineStyle();
467 				}
468 				if (static_cast<const SwNumRuleItem &>(rItem).GetValue() ==
469                     pOutlineRule->GetName())
470                 {
471                     rTxtColl.ResetFmtAttr(RES_PARATR_NUMRULE);
472                 }
473             }
474             else
475             {
476 				rTxtColl.AssignToListLevelOfOutlineStyle(GetLevel(rTxtColl.GetName()));
477 
478 				if (static_cast<const SwNumRuleItem &>(rItem).GetValue() !=
479                     pOutlineRule->GetName())
480                 {
481                     SwNumRuleItem aItem(pOutlineRule->GetName());
482                     rTxtColl.SetFmtAttr(aItem);
483                 }
484             }							//<-end,zhaojianwei
485         }
486 	}
487 
488     for(i = 0; i < MAXLEVEL; ++i )
489     {
490         String sHeadline;
491         ::SwStyleNameMapper::FillUIName( static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i),
492                                          sHeadline );
493         SwTxtFmtColl* pColl = rWrtSh.FindTxtFmtCollByName( sHeadline );
494         if( !pColl )
495         {
496 			//if( !aCollNames[i].Len() )			//#outline level,removed by zhaojianwei
497 			//{
498 			//	SwTxtFmtColl* pTxtColl = rWrtSh.GetTxtCollFromPool(
499 			//		static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i) );
500 			//	pTxtColl->SetOutlineLevel( NO_NUMBERING );
501 			//	pTxtColl->ResetFmtAttr(RES_PARATR_NUMRULE);
502 			//}
503 			//else if(aCollNames[i] != sHeadline)
504 			//{
505 			//	SwTxtFmtColl* pTxtColl = rWrtSh.GetParaStyle(
506 			//		aCollNames[i], SwWrtShell::GETSTYLE_CREATESOME);
507 			//	if(pTxtColl)
508 			//	{
509 			//		pTxtColl->SetOutlineLevel( static_cast< sal_uInt8 >(i) );
510 
511 			//		SwNumRuleItem aItem(pOutlineRule->GetName());
512 			//		pTxtColl->SetFmtAttr(aItem);
513 			//	}
514 			//}
515             if(aCollNames[i] != sHeadline)//->added by zhaojianwei
516             {
517 				SwTxtFmtColl* pTxtColl = rWrtSh.GetTxtCollFromPool(
518 					static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i) );
519 				pTxtColl->DeleteAssignmentToListLevelOfOutlineStyle();
520 				pTxtColl->ResetFmtAttr(RES_PARATR_NUMRULE);
521 
522 				if( aCollNames[i].Len() )
523 				{
524 					pTxtColl = rWrtSh.GetParaStyle(
525                                 aCollNames[i], SwWrtShell::GETSTYLE_CREATESOME);
526 					if(pTxtColl)
527 					{
528 						pTxtColl->AssignToListLevelOfOutlineStyle(i);
529 						SwNumRuleItem aItem(pOutlineRule->GetName());
530 						pTxtColl->SetFmtAttr(aItem);
531 					}
532                 }
533             }//<--end,zhaojianwei
534         }
535     }
536 
537 	rWrtSh.SetOutlineNumRule( *pNumRule);
538 
539     // --> OD 2006-12-11 #130443#
540     rWrtSh.EndAction();
541     // <--
542 
543 	return RET_OK;
544 }
545 
546 /* -----------------07.07.98 14:19-------------------
547  *
548  * --------------------------------------------------*/
549 SwOutlineSettingsTabPage::SwOutlineSettingsTabPage(Window* pParent, const SfxItemSet& rSet) :
550 	SfxTabPage(pParent, SW_RES(TP_OUTLINE_NUM), rSet),
551     aLevelFL(       this, SW_RES(FL_LEVEL    )),
552     aLevelLB(       this, SW_RES(LB_LEVEL   )),
553 	aNumberFL(this, SW_RES(FL_NUMBER)),
554     aCollLbl(this, SW_RES(FT_COLL)),
555 	aCollBox(this, SW_RES(LB_COLL)),
556     aNumberLbl(this, SW_RES(FT_NUMBER)),
557     aNumberBox(this, SW_RES(LB_NUMBER), INSERT_NUM_TYPE_NO_NUMBERING|INSERT_NUM_EXTENDED_TYPES),
558 	aCharFmtFT(this, SW_RES(FT_CHARFMT)),
559 	aCharFmtLB(this, SW_RES(LB_CHARFMT)),
560 	aAllLevelFT(	this, SW_RES(FT_ALL_LEVEL)),
561 	aAllLevelNF(	this, SW_RES(NF_ALL_LEVEL)),
562 	aDelim(this, SW_RES(FT_DELIM)),
563 	aPrefixFT(this, SW_RES(FT_PREFIX)),
564 	aPrefixED(this, SW_RES(ED_PREFIX)),
565 	aSuffixFT(this, SW_RES(FT_SUFFIX)),
566 	aSuffixED(this, SW_RES(ED_SUFFIX)),
567 	aStartLbl(this, SW_RES(FT_START)),
568 	aStartEdit(this, SW_RES(ED_START)),
569     aPreviewWIN(    this, SW_RES(WIN_PREVIEW )),
570 
571     aNoFmtName(SW_RES(ST_NO_COLL)),
572     pSh(0),
573     pCollNames(0),
574     nActLevel(1)
575 {
576 	FreeResource();
577 	SetExchangeSupport();
578 
579 	aCollBox.InsertEntry(aNoFmtName);
580 	aLevelLB.SetSelectHdl(LINK(this, 	SwOutlineSettingsTabPage, LevelHdl));
581 	aAllLevelNF.SetModifyHdl(LINK(this, SwOutlineSettingsTabPage, ToggleComplete));
582 	aCollBox.SetSelectHdl(LINK(this, 	SwOutlineSettingsTabPage, CollSelect));
583 	aCollBox.SetGetFocusHdl(LINK(this, 	SwOutlineSettingsTabPage, CollSelectGetFocus));
584 	aNumberBox.SetSelectHdl(LINK(this, 	SwOutlineSettingsTabPage, NumberSelect));
585 	aPrefixED.SetModifyHdl(LINK(this, 	SwOutlineSettingsTabPage, DelimModify));
586 	aSuffixED.SetModifyHdl(LINK(this, 	SwOutlineSettingsTabPage, DelimModify));
587 	aStartEdit.SetModifyHdl(LINK(this, 	SwOutlineSettingsTabPage, StartModified));
588 	aCharFmtLB.SetSelectHdl(LINK(this, 	SwOutlineSettingsTabPage, CharFmtHdl));
589 
590 }
591 /* -----------------07.07.98 14:19-------------------
592  *
593  * --------------------------------------------------*/
594 void   	SwOutlineSettingsTabPage::Update()
595 {
596 		// falls eine Vorlage fuer diese Ebene bereits selektiert wurde,
597 		// diese in der ListBox auswaehlean
598 	aCollBox.Enable(USHRT_MAX != nActLevel);
599 	if(USHRT_MAX == nActLevel)
600 	{
601 		sal_Bool bSamePrefix = sal_True;
602 		sal_Bool bSameSuffix = sal_True;
603 		sal_Bool bSameType = sal_True;
604 		sal_Bool bSameComplete = sal_True;
605 		sal_Bool bSameStart = sal_True;
606 		sal_Bool bSameCharFmt = sal_True;
607 
608 		const SwNumFmt* aNumFmtArr[MAXLEVEL];
609 		const SwCharFmt* pFirstFmt = 0;
610 
611 		for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
612 		{
613 
614 			aNumFmtArr[ i ] = &pNumRule->Get(i);
615 			if(i == 0)
616 				pFirstFmt = aNumFmtArr[i]->GetCharFmt();
617 			else
618 			{
619 				bSameType 	&= aNumFmtArr[i]->GetNumberingType() == aNumFmtArr[0]->GetNumberingType();
620 				bSameStart	&= aNumFmtArr[i]->GetStart() == aNumFmtArr[0]->GetStart();
621 				bSamePrefix &= aNumFmtArr[i]->GetPrefix() == aNumFmtArr[0]->GetPrefix();
622 				bSameSuffix &= aNumFmtArr[i]->GetSuffix() == aNumFmtArr[0]->GetSuffix();
623 				bSameComplete &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[0]->GetIncludeUpperLevels();
624 				const SwCharFmt* pFmt = aNumFmtArr[i]->GetCharFmt();
625 				bSameCharFmt &= 	(!pFirstFmt && !pFmt)
626 									|| (pFirstFmt && pFmt && pFmt->GetName() == pFirstFmt->GetName());
627 			}
628 		}
629         CheckForStartValue_Impl(aNumFmtArr[0]->GetNumberingType());
630         if(bSameType)
631 			aNumberBox.SelectNumberingType( aNumFmtArr[0]->GetNumberingType() );
632 		else
633 			aNumberBox.SetNoSelection();
634 		if(bSameStart)
635 			aStartEdit.SetValue(aNumFmtArr[0]->GetStart());
636 		else
637 			aStartEdit.SetText(aEmptyStr);
638 		if(bSamePrefix)
639 			aPrefixED.SetText(aNumFmtArr[0]->GetPrefix());
640 		else
641 			aPrefixED.SetText(aEmptyStr);
642 		if(bSameSuffix)
643 			aSuffixED.SetText(aNumFmtArr[0]->GetSuffix());
644 		else
645 			aSuffixED.SetText(aEmptyStr);
646 
647 		if(bSameCharFmt)
648 		{
649 			if(pFirstFmt)
650 				aCharFmtLB.SelectEntry(pFirstFmt->GetName());
651 			else
652 				aCharFmtLB.SelectEntry( ViewShell::GetShellRes()->aStrNone );
653 		}
654 		else
655 			aCharFmtLB.SetNoSelection();
656 
657 		aAllLevelFT.Enable(sal_True);
658 		aAllLevelNF.Enable(sal_True);
659 		aAllLevelNF.SetMax(MAXLEVEL);
660 		if(bSameComplete)
661 		{
662 			aAllLevelNF.SetValue(aNumFmtArr[0]->GetIncludeUpperLevels());
663 		}
664 		else
665 		{
666 			aAllLevelNF.SetText(aEmptyStr);
667 		}
668 	}
669 	else
670 	{
671 		sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel);
672 		String aColl(pCollNames[nTmpLevel]);
673 		if(aColl.Len())
674 			aCollBox.SelectEntry(aColl);
675 		else
676 			aCollBox.SelectEntry(aNoFmtName);
677 		const SwNumFmt &rFmt = pNumRule->Get(nTmpLevel);
678 
679 		aNumberBox.SelectNumberingType( rFmt.GetNumberingType() );
680 		aPrefixED.SetText(rFmt.GetPrefix());
681 		aSuffixED.SetText(rFmt.GetSuffix());
682 		const SwCharFmt* pFmt = rFmt.GetCharFmt();
683 		if(pFmt)
684 			aCharFmtLB.SelectEntry(pFmt->GetName());
685 		else
686 			aCharFmtLB.SelectEntry( ViewShell::GetShellRes()->aStrNone );
687 
688 		if(nTmpLevel)
689 		{
690 			aAllLevelFT.Enable(sal_True);
691 			aAllLevelNF.Enable(sal_True);
692 			aAllLevelNF.SetMax(nTmpLevel + 1);
693 			aAllLevelNF.SetValue(rFmt.GetIncludeUpperLevels());
694 		}
695 		else
696 		{
697 			aAllLevelNF.SetText(aEmptyStr);
698 			aAllLevelNF.Enable(sal_False);
699 			aAllLevelFT.Enable(sal_False);
700 		}
701         CheckForStartValue_Impl(rFmt.GetNumberingType());
702 		aStartEdit.SetValue( rFmt.GetStart() );
703 	}
704 	SetModified();
705 }
706 
707 /* -----------------07.07.98 14:19-------------------
708  *
709  * --------------------------------------------------*/
710 IMPL_LINK( SwOutlineSettingsTabPage, LevelHdl, ListBox *, pBox )
711 {
712 	nActLevel = 0;
713 	if(pBox->IsEntryPosSelected( MAXLEVEL ))
714 	{
715 		nActLevel = 0xFFFF;
716 	}
717 	else
718 	{
719 		sal_uInt16 nMask = 1;
720 		for( sal_uInt16 i = 0; i < MAXLEVEL; i++ )
721 		{
722 			if(pBox->IsEntryPosSelected( i ))
723 				nActLevel |= nMask;
724 			nMask <<= 1;
725 		}
726 	}
727 	Update();
728 	return 0;
729 }
730 /* -----------------07.07.98 14:19-------------------
731  *
732  * --------------------------------------------------*/
733 IMPL_LINK( SwOutlineSettingsTabPage, ToggleComplete, NumericField *, pFld )
734 {
735 	sal_uInt16 nMask = 1;
736 	for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
737 	{
738 		if(nActLevel & nMask)
739 		{
740 			SwNumFmt aNumFmt(pNumRule->Get(i));
741 			aNumFmt.SetIncludeUpperLevels( Min( (sal_uInt8)pFld->GetValue(),
742 												(sal_uInt8)(i + 1)) );
743 			pNumRule->Set(i, aNumFmt);
744 		}
745 		nMask <<= 1;
746 	}
747 	SetModified();
748 	return 0;
749 }
750 /* -----------------07.07.98 14:19-------------------
751  *
752  * --------------------------------------------------*/
753 IMPL_LINK( SwOutlineSettingsTabPage, CollSelect, ListBox *, pBox )
754 {
755 	sal_uInt8 i;
756 
757 	const String aCollName(pBox->GetSelectEntry());
758 	//0xFFFF darf hier nicht sein (disable)
759 	sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel);
760 	String sOldName( pCollNames[nTmpLevel] );
761 
762 	for( i = 0; i < MAXLEVEL; ++i)
763 		pCollNames[i] = aSaveCollNames[i];
764 
765 	if(aCollName == aNoFmtName)
766 		pCollNames[nTmpLevel] = aEmptyStr;
767 	else
768 	{
769 		pCollNames[nTmpLevel] = aCollName;
770 				// wird die Vorlage bereits verwendet ?
771 		for( i = 0; i < MAXLEVEL; ++i)
772 			if(i != nTmpLevel && pCollNames[i] == aCollName )
773 				pCollNames[i] = aEmptyStr;
774 	}
775 
776 	// search the oldname and put it into the current entries
777 	if( sOldName.Len() )
778 		for( i = 0; i < MAXLEVEL; ++i)
779 			if( aSaveCollNames[ i ] == sOldName && i != nTmpLevel &&
780 				!pCollNames[ i ].Len() )
781 			{
782 				sal_uInt8 n;
783 				for( n = 0; n < MAXLEVEL; ++n )
784 					if( pCollNames[ n ] == sOldName )
785 						break;
786 
787 				if( MAXLEVEL == n )
788 					// it was a outline leveld name and the current entries is zero.
789 					pCollNames[ i ] = sOldName;
790 			}
791 
792 	SetModified();
793 	return 0;
794 }
795 
796 IMPL_LINK( SwOutlineSettingsTabPage, CollSelectGetFocus, ListBox *, EMPTYARG )
797 {
798 	for( sal_uInt8 i = 0; i < MAXLEVEL; ++i)
799 		aSaveCollNames[i] =  pCollNames[i];
800 	return 0;
801 }
802 
803 /* -----------------07.07.98 14:19-------------------
804  *
805  * --------------------------------------------------*/
806 IMPL_LINK( SwOutlineSettingsTabPage, NumberSelect, SwNumberingTypeListBox *, pBox )
807 {
808 	sal_uInt16 nMask = 1;
809 	sal_Int16 nNumberType = pBox->GetSelectedNumberingType();//(sal_Int16)(sal_uLong)pBox->GetEntryData(pBox->GetSelectEntryPos());
810 	for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
811 	{
812 		if(nActLevel & nMask)
813 		{
814 			SwNumFmt aNumFmt(pNumRule->Get(i));
815 			aNumFmt.SetNumberingType(nNumberType);
816 			pNumRule->Set(i, aNumFmt);
817             CheckForStartValue_Impl(nNumberType);
818         }
819 		nMask <<= 1;
820 	}
821 	SetModified();
822 	return 0;
823 }
824 /* -----------------07.07.98 14:19-------------------
825  *
826  * --------------------------------------------------*/
827 IMPL_LINK( SwOutlineSettingsTabPage, DelimModify, Edit *, EMPTYARG )
828 {
829 	sal_uInt16 nMask = 1;
830 	for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
831 	{
832 		if(nActLevel & nMask)
833 		{
834 			SwNumFmt aNumFmt(pNumRule->Get(i));
835 			aNumFmt.SetPrefix( aPrefixED.GetText() );
836 			aNumFmt.SetSuffix( aSuffixED.GetText() );
837 			pNumRule->Set(i, aNumFmt);
838 		}
839 		nMask <<= 1;
840 	}
841 	SetModified();
842 	return 0;
843 }
844 /* -----------------07.07.98 14:19-------------------
845  *
846  * --------------------------------------------------*/
847 IMPL_LINK( SwOutlineSettingsTabPage, StartModified, NumericField *, pFld )
848 {
849 	sal_uInt16 nMask = 1;
850 	for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
851 	{
852 		if(nActLevel & nMask)
853 		{
854 			SwNumFmt aNumFmt(pNumRule->Get(i));
855 			aNumFmt.SetStart( (sal_uInt16)pFld->GetValue() );
856 			pNumRule->Set(i, aNumFmt);
857 		}
858 		nMask <<= 1;
859 	}
860     SetModified();
861 	return 0;
862 }
863 /* -----------------21.09.98 12:21-------------------
864  *
865  * --------------------------------------------------*/
866 IMPL_LINK( SwOutlineSettingsTabPage, CharFmtHdl, ListBox *, EMPTYARG )
867 {
868 //	bAutomaticCharStyles = sal_False;
869 	String sEntry = aCharFmtLB.GetSelectEntry();
870 	sal_uInt16 nMask = 1;
871 	sal_Bool bFormatNone = sEntry == ViewShell::GetShellRes()->aStrNone;
872 	SwCharFmt* pFmt = 0;
873 	if(!bFormatNone)
874 	{
875 		sal_uInt16 nChCount = pSh->GetCharFmtCount();
876 		for(sal_uInt16 i = 0; i < nChCount; i++)
877 		{
878 			SwCharFmt& rChFmt = pSh->GetCharFmt(i);
879 			if(rChFmt.GetName() == sEntry)
880 			{
881 				pFmt = &rChFmt;
882 				break;
883 			}
884 		}
885 		if(!pFmt)
886 		{
887 			SfxStyleSheetBasePool* pPool = pSh->GetView().GetDocShell()->GetStyleSheetPool();
888 			SfxStyleSheetBase* pBase;
889 			pBase = pPool->Find(sEntry, SFX_STYLE_FAMILY_CHAR);
890 			if(!pBase)
891 				pBase = &pPool->Make(sEntry, SFX_STYLE_FAMILY_PAGE);
892 			pFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
893 
894 		}
895 	}
896 
897 	for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
898 	{
899 		if(nActLevel & nMask)
900 		{
901 			SwNumFmt aNumFmt(pNumRule->Get(i));
902 			if(bFormatNone)
903 				aNumFmt.SetCharFmt(0);
904 			else
905 				aNumFmt.SetCharFmt(pFmt);
906 			pNumRule->Set(i, aNumFmt);
907 		}
908 		nMask <<= 1;
909 	}
910 	return RET_OK;
911 }
912 /* -----------------07.07.98 14:19-------------------
913  *
914  * --------------------------------------------------*/
915 SwOutlineSettingsTabPage::~SwOutlineSettingsTabPage()
916 {
917 }
918 /* -----------------07.07.98 16:27-------------------
919  *
920  * --------------------------------------------------*/
921 void SwOutlineSettingsTabPage::SetWrtShell(SwWrtShell* pShell)
922 {
923 	pSh = pShell;
924 	// Erfragen der NumRules dieses Dokumentes
925 	pNumRule = ((SwOutlineTabDialog*)GetTabDialog())->GetNumRule();
926 	pCollNames = ((SwOutlineTabDialog*)GetTabDialog())->GetCollNames();
927 
928 	//pNumRule = new SwNumRule( *rSh.GetOutlineNumRule() );
929 
930 	aPreviewWIN.SetNumRule(pNumRule);
931 	aPreviewWIN.SetOutlineNames(pCollNames);
932 	// Startwert setzen - nActLevel muss hier 1 sein
933 	sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel);
934 	const SwNumFmt& rNumFmt = pNumRule->Get( nTmpLevel );
935 	aStartEdit.SetValue( rNumFmt.GetStart() );
936 
937 	// Poolformate fuer Ueberschriften anlegen
938 	String sStr;
939 	sal_uInt16 i;
940 	for( i = 0; i < MAXLEVEL; ++i )
941 	{
942 		aCollBox.InsertEntry( SwStyleNameMapper::GetUIName(
943                                     static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i), aEmptyStr ));
944 		aLevelLB.InsertEntry( String::CreateFromInt32(i + 1) );
945 	}
946 	sStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "1 - " ));
947 	sStr += String::CreateFromInt32(MAXLEVEL);
948 	aLevelLB.InsertEntry( sStr );
949 
950 	// Erfragen der Gliederungsebenen der Textvorlagen
951 	const sal_uInt16 nCount = pSh->GetTxtFmtCollCount();
952 	for( i = 0; i < nCount; ++i )
953 	{
954 		SwTxtFmtColl &rTxtColl = pSh->GetTxtFmtColl(i);
955 		if(!rTxtColl.IsDefault())
956 		{
957 			sStr = rTxtColl.GetName();
958 			if(LISTBOX_ENTRY_NOTFOUND == aCollBox.GetEntryPos( sStr ))
959 				aCollBox.InsertEntry( sStr );
960 		}
961 	}
962 
963 	aNumberBox.SelectNumberingType(rNumFmt.GetNumberingType());
964 	sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL);
965 	sal_uInt16 nTmp = 0;
966 	if(nOutlinePos != USHRT_MAX)
967 	{
968         nTmp = static_cast<sal_uInt16>(pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos));
969 	}
970 	aLevelLB.SelectEntryPos(nTmp-1);//nTmp);//#outline level,zhaojianwei
971 
972 	// Zeichenvorlagen sammeln
973 	aCharFmtLB.Clear();
974 	aCharFmtLB.InsertEntry( ViewShell::GetShellRes()->aStrNone );
975 
976 	// Zeichenvorlagen
977 	::FillCharStyleListBox(aCharFmtLB,
978 						pSh->GetView().GetDocShell());
979 	Update();
980 }
981 /* -----------------07.07.98 14:19-------------------
982  *
983  * --------------------------------------------------*/
984 void    SwOutlineSettingsTabPage::ActivatePage(const SfxItemSet& )
985 {
986     nActLevel = SwOutlineTabDialog::GetActNumLevel();
987 	if(nActLevel != USHRT_MAX)
988 		aLevelLB.SelectEntryPos(lcl_BitToLevel(nActLevel));
989 	else
990 		aLevelLB.SelectEntryPos(MAXLEVEL);
991 	LevelHdl(&aLevelLB);
992 }
993 /* -----------------07.07.98 14:19-------------------
994  *
995  * --------------------------------------------------*/
996 int     SwOutlineSettingsTabPage::DeactivatePage(SfxItemSet*)
997 {
998     SwOutlineTabDialog::SetActNumLevel(nActLevel);
999 	return LEAVE_PAGE;
1000 }
1001 /* -----------------07.07.98 14:19-------------------
1002  *
1003  * --------------------------------------------------*/
1004 sal_Bool    SwOutlineSettingsTabPage::FillItemSet( SfxItemSet&  )
1005 {
1006 	return sal_True;
1007 }
1008 /* -----------------07.07.98 14:19-------------------
1009  *
1010  * --------------------------------------------------*/
1011 void 	SwOutlineSettingsTabPage::Reset( const SfxItemSet& rSet )
1012 {
1013 	ActivatePage(rSet);
1014 }
1015 /* -----------------07.07.98 14:19-------------------
1016  *
1017  * --------------------------------------------------*/
1018 SfxTabPage*	SwOutlineSettingsTabPage::Create( Window* pParent,
1019 								const SfxItemSet& rAttrSet)
1020 {
1021 	return new SwOutlineSettingsTabPage(pParent, rAttrSet);
1022 }
1023 /* -----------------07.11.2002 15:13-----------------
1024  *
1025  * --------------------------------------------------*/
1026 void SwOutlineSettingsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType)
1027 {
1028     sal_Bool bIsNull = aStartEdit.GetValue() == 0;
1029     sal_Bool bNoZeroAllowed = nNumberingType < SVX_NUM_ARABIC ||
1030                         SVX_NUM_CHARS_UPPER_LETTER_N == nNumberingType ||
1031                         SVX_NUM_CHARS_LOWER_LETTER_N == nNumberingType;
1032     aStartEdit.SetMin(bNoZeroAllowed ? 1 : 0);
1033     if(bIsNull && bNoZeroAllowed)
1034         aStartEdit.GetModifyHdl().Call(&aStartEdit);
1035 }
1036 /*-----------------09.12.97 11:54-------------------
1037 
1038 --------------------------------------------------*/
1039 sal_uInt16 lcl_DrawBullet(VirtualDevice* pVDev,
1040 			const SwNumFmt& rFmt, sal_uInt16 nXStart,
1041 			sal_uInt16 nYStart, const Size& rSize)
1042 {
1043 	Font aTmpFont(pVDev->GetFont());
1044 
1045 	Font aFont(*rFmt.GetBulletFont());
1046 	aFont.SetSize(rSize);
1047 	aFont.SetTransparent(sal_True);
1048 	pVDev->SetFont( aFont );
1049 	String aText(rFmt.GetBulletChar());
1050 	pVDev->DrawText( Point(nXStart, nYStart), aText );
1051 	sal_uInt16 nRet = (sal_uInt16)pVDev->GetTextWidth(aText);
1052 
1053 	pVDev->SetFont(aTmpFont);
1054 	return nRet;
1055 }
1056 /*-----------------09.12.97 11:49-------------------
1057 
1058 --------------------------------------------------*/
1059 sal_uInt16 lcl_DrawGraphic(VirtualDevice* pVDev, const SwNumFmt &rFmt, sal_uInt16 nXStart,
1060 						sal_uInt16 nYStart, sal_uInt16 nDivision)
1061 {
1062 	const SvxBrushItem* pBrushItem = rFmt.GetBrush();
1063 	sal_uInt16 nRet = 0;
1064 	if(pBrushItem)
1065 	{
1066 		const Graphic* pGrf = pBrushItem->GetGraphic();
1067 		if(pGrf)
1068 		{
1069 			Size aGSize( rFmt.GetGraphicSize());
1070 			aGSize.Width() /= nDivision;
1071 			nRet = (sal_uInt16)aGSize.Width();
1072 			aGSize.Height() /= nDivision;
1073 			pGrf->Draw( pVDev, Point(nXStart,nYStart),
1074 					pVDev->PixelToLogic( aGSize ) );
1075 		}
1076 	}
1077 	return nRet;
1078 
1079 }
1080 /*-----------------02.12.97 10:34-------------------
1081 	Vorschau der Numerierung painten
1082 --------------------------------------------------*/
1083 void    NumberingPreview::Paint( const Rectangle& /*rRect*/ )
1084 {
1085 	Size aSize(PixelToLogic(GetOutputSizePixel()));
1086 	Rectangle aRect(Point(0,0), aSize);
1087 
1088 	VirtualDevice* pVDev = new VirtualDevice(*this);
1089 	pVDev->SetMapMode(GetMapMode());
1090 	pVDev->SetOutputSize( aSize );
1091 
1092 	// #101524# OJ
1093 	pVDev->SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
1094 	pVDev->SetLineColor( GetSettings().GetStyleSettings().GetButtonTextColor() );
1095 	pVDev->DrawRect(aRect);
1096 
1097 	if(pActNum)
1098 	{
1099 		sal_uInt16 nWidthRelation;
1100 		if(nPageWidth)
1101 		{
1102 			nWidthRelation = sal_uInt16 (nPageWidth / aSize.Width());
1103 			if(bPosition)
1104 				nWidthRelation = nWidthRelation * 2 / 3;
1105 			else
1106 				nWidthRelation = nWidthRelation / 4;
1107 		}
1108 		else
1109 			nWidthRelation = 30; // Kapiteldialog
1110 
1111 		//Hoehe pro Ebene
1112         sal_uInt16 nXStep = sal_uInt16(aSize.Width() / (3 * MAXLEVEL));
1113 		if(MAXLEVEL < 10)
1114 			nXStep /= 2;
1115 		sal_uInt16 nYStart = 4;
1116         sal_uInt16 nYStep = sal_uInt16((aSize.Height() - 6)/ MAXLEVEL);
1117         aStdFont = OutputDevice::GetDefaultFont(
1118                                     DEFAULTFONT_UI_SANS, (LanguageType)GetAppLanguage(),
1119 									DEFAULTFONT_FLAGS_ONLYONE, this );
1120 		// #101524# OJ
1121         aStdFont.SetColor( SwViewOption::GetFontColor() );
1122 
1123 		//
1124 		sal_uInt16 nFontHeight = nYStep * 6 / 10;
1125 		if(bPosition)
1126 			nFontHeight = nYStep * 15 / 10;
1127 		aStdFont.SetSize(Size( 0, nFontHeight ));
1128 
1129 		sal_uInt16 nPreNum = pActNum->Get(0).GetStart();
1130 
1131 		if(bPosition)
1132 		{
1133 			sal_uInt16 nLineHeight = nFontHeight * 8 / 7;
1134 			sal_uInt8 nStart = 0;
1135 			while( !(nActLevel & (1<<nStart)) )
1136 			{
1137 				nStart++;
1138 			}
1139 			if(nStart) // damit moeglichs Vorgaenger und Nachfolger gezeigt werden
1140 				nStart--;
1141 
1142             SwNumberTree::tNumberVector aNumVector;
1143 			sal_uInt8 nEnd = Min( (sal_uInt8)(nStart + 3), MAXLEVEL );
1144 			for( sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel )
1145 			{
1146 				const SwNumFmt &rFmt = pActNum->Get(nLevel);
1147 				aNumVector.push_back(rFmt.GetStart());
1148 
1149                 // --> OD 2008-02-01 #newlistlevelattrs#
1150                 sal_uInt16 nXStart( 0 );
1151                 short nTextOffset( 0 );
1152                 sal_uInt16 nNumberXPos( 0 );
1153                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1154                 {
1155                     nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
1156                     nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation;
1157                     nNumberXPos = nXStart;
1158                     sal_uInt16 nFirstLineOffset = (-rFmt.GetFirstLineOffset()) / nWidthRelation;
1159 
1160                     if(nFirstLineOffset <= nNumberXPos)
1161                         nNumberXPos = nNumberXPos - nFirstLineOffset;
1162                     else
1163                         nNumberXPos = 0;
1164                 }
1165                 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1166                 {
1167                     const long nTmpNumberXPos( ( rFmt.GetIndentAt() +
1168                                                  rFmt.GetFirstLineIndent() ) /
1169                                                nWidthRelation );
1170                     if ( nTmpNumberXPos < 0 )
1171                     {
1172                         nNumberXPos = 0;
1173                     }
1174                     else
1175                     {
1176                         nNumberXPos = static_cast<sal_uInt16>(nTmpNumberXPos);
1177                     }
1178                 }
1179                 // <--
1180 
1181 				sal_uInt16 nBulletWidth = 0;
1182 				if( SVX_NUM_BITMAP == rFmt.GetNumberingType() )
1183 				{
1184 					nBulletWidth = lcl_DrawGraphic(pVDev, rFmt,
1185 										nNumberXPos,
1186 											nYStart, nWidthRelation);
1187 				}
1188 				else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
1189 				{
1190 					nBulletWidth =  lcl_DrawBullet(pVDev, rFmt, nNumberXPos, nYStart, aStdFont.GetSize());
1191 				}
1192 				else
1193 				{
1194 					pVDev->SetFont(aStdFont);
1195 					if(pActNum->IsContinusNum())
1196 						aNumVector[nLevel] = nPreNum;
1197                     // --> OD 2005-11-17 #128041#
1198                     String aText(pActNum->MakeNumString( aNumVector ));
1199                     // <--
1200 					pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
1201 					nBulletWidth = (sal_uInt16)pVDev->GetTextWidth(aText);
1202 					nPreNum++;
1203 				}
1204                 // --> OD 2008-02-01 #newlistlevelattrs#
1205                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT &&
1206                      rFmt.GetLabelFollowedBy() == SvxNumberFormat::SPACE )
1207                 {
1208                     pVDev->SetFont(aStdFont);
1209                     String aText(' ');
1210                     pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
1211                     nBulletWidth = nBulletWidth + (sal_uInt16)pVDev->GetTextWidth(aText);
1212                 }
1213                 // <--
1214 
1215                 // --> OD 2008-02-01 #newlistlevelattrs#
1216                 sal_uInt16 nTextXPos( 0 );
1217                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1218                 {
1219                     nTextXPos = nXStart;
1220                     if(nTextOffset < 0)
1221                          nTextXPos = nTextXPos + nTextOffset;
1222                     if(nNumberXPos + nBulletWidth + nTextOffset > nTextXPos )
1223                         nTextXPos = nNumberXPos + nBulletWidth + nTextOffset;
1224                 }
1225                 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1226                 {
1227                     switch ( rFmt.GetLabelFollowedBy() )
1228                     {
1229                         case SvxNumberFormat::LISTTAB:
1230                         {
1231                             nTextXPos = static_cast<sal_uInt16>(
1232                                             rFmt.GetListtabPos() / nWidthRelation );
1233                             if ( nTextXPos < nNumberXPos + nBulletWidth )
1234                             {
1235                                 nTextXPos = nNumberXPos + nBulletWidth;
1236                             }
1237                         }
1238                         break;
1239                         case SvxNumberFormat::SPACE:
1240                         case SvxNumberFormat::NOTHING:
1241                         {
1242                             nTextXPos = nNumberXPos + nBulletWidth;
1243                         }
1244                         break;
1245                     }
1246 
1247                     nXStart = static_cast<sal_uInt16>( rFmt.GetIndentAt() / nWidthRelation );
1248                 }
1249                 // <--
1250 
1251 
1252                 Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2));
1253 				pVDev->SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() ); // Color( COL_BLACK ) );
1254 				pVDev->DrawRect( aRect1 );
1255 
1256 				Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2));
1257 				pVDev->DrawRect( aRect2 );
1258 				nYStart += 2 * nLineHeight;
1259 			}
1260 		}
1261 		else
1262 		{
1263             SwNumberTree::tNumberVector aNumVector;
1264 			sal_uInt16 nLineHeight = nFontHeight * 3 / 2;
1265 			for( sal_uInt8 nLevel = 0; nLevel < MAXLEVEL;
1266                             ++nLevel, nYStart = nYStart + nYStep )
1267 			{
1268 				const SwNumFmt &rFmt = pActNum->Get(nLevel);
1269 				aNumVector.push_back(rFmt.GetStart());
1270                 // --> OD 2008-02-01 #newlistlevelattrs#
1271                 sal_uInt16 nXStart( 0 );
1272                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1273                 {
1274                     nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
1275                 }
1276                 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1277                 {
1278                     const long nTmpXStart( ( rFmt.GetIndentAt() +
1279                                              rFmt.GetFirstLineIndent() ) /
1280                                            nWidthRelation );
1281                     if ( nTmpXStart < 0 )
1282                     {
1283                         nXStart = 0;
1284                     }
1285                     else
1286                     {
1287                         nXStart = static_cast<sal_uInt16>(nTmpXStart);
1288                     }
1289                 }
1290                 nXStart /= 2;
1291                 nXStart += 2;
1292                 // <--
1293 				sal_uInt16 nTextOffset = 2 * nXStep;
1294 				if( SVX_NUM_BITMAP == rFmt.GetNumberingType() )
1295 				{
1296 					lcl_DrawGraphic(pVDev, rFmt, nXStart, nYStart, nWidthRelation);
1297 					nTextOffset = nLineHeight + nXStep;
1298 				}
1299 				else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
1300 				{
1301 					nTextOffset =  lcl_DrawBullet(pVDev, rFmt, nXStart, nYStart, aStdFont.GetSize());
1302                     nTextOffset = nTextOffset + nXStep;
1303 				}
1304 				else
1305 				{
1306 					pVDev->SetFont(aStdFont);
1307 					if(pActNum->IsContinusNum())
1308 						aNumVector[nLevel] = nPreNum;
1309                     // --> OD 2005-11-17 #128041#
1310                     String aText(pActNum->MakeNumString( aNumVector ));
1311                     // <--
1312 					pVDev->DrawText( Point(nXStart, nYStart), aText );
1313 					nTextOffset = (sal_uInt16)pVDev->GetTextWidth(aText);
1314                     nTextOffset = nTextOffset + nXStep;
1315 					nPreNum++;
1316 				}
1317 				pVDev->SetFont(aStdFont);
1318 
1319 				// Changed as per BugID 79541 Branding/Configuration
1320                 uno::Any MyAny = ::utl::ConfigManager::GetConfigManager()->
1321                         GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME );
1322                 ::rtl::OUString aProductName;
1323 
1324 				MyAny >>= aProductName;
1325 				String sMsg(C2S("%PRODUCTNAME"));
1326 				sMsg.SearchAndReplaceAscii( "%PRODUCTNAME" , aProductName );
1327 
1328 				if(pOutlineNames)
1329 					sMsg = pOutlineNames[nLevel];
1330 				pVDev->DrawText( Point(nXStart + nTextOffset, nYStart), sMsg );
1331 			}
1332 		}
1333 	}
1334 	DrawOutDev(	Point(0,0), aSize,
1335 				Point(0,0), aSize,
1336 						*pVDev );
1337 	delete pVDev;
1338 
1339 }
1340 
1341 /*-----------------02.12.97 10:34-------------------
1342 
1343 --------------------------------------------------*/
1344 NumberingPreview::~NumberingPreview()
1345 {
1346 }
1347 
1348 
1349