xref: /aoo42x/main/cui/source/tabpages/numpages.cxx (revision c7be74b1)
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_cui.hxx"
26 
27 #include <com/sun/star/text/HoriOrientation.hpp>
28 #include <com/sun/star/text/VertOrientation.hpp>
29 #include <com/sun/star/text/RelOrientation.hpp>
30 
31 #include <numpages.hxx>
32 #include <numpages.hrc>
33 #include <dialmgr.hxx>
34 #include <cuires.hrc>
35 #include <tools/shl.hxx>
36 #include <i18npool/mslangid.hxx>
37 #include <svtools/valueset.hxx>
38 #include <helpid.hrc>
39 #include <editeng/numitem.hxx>
40 #include <svl/eitem.hxx>
41 #include <vcl/svapp.hxx>
42 #include <svx/gallery.hxx>
43 #include <svl/urihelper.hxx>
44 #include <editeng/brshitem.hxx>
45 #include <svl/intitem.hxx>
46 #include <sfx2/objsh.hxx>
47 #include <vcl/graph.hxx>
48 #include <vcl/msgbox.hxx>
49 #include "cuicharmap.hxx"
50 #include <editeng/flstitem.hxx>
51 #include <svx/dlgutil.hxx>
52 #include <svx/xtable.hxx>
53 #include <svx/drawitem.hxx>
54 #include <svx/numvset.hxx>
55 #include <svx/htmlmode.hxx>
56 #include <unotools/pathoptions.hxx>
57 #include <svtools/ctrltool.hxx>
58 #include <editeng/unolingu.hxx>
59 #include <com/sun/star/style/NumberingType.hpp>
60 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
61 #include <com/sun/star/container/XIndexAccess.hpp>
62 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
63 #include <com/sun/star/text/XNumberingFormatter.hpp>
64 #include <com/sun/star/beans/PropertyValue.hpp>
65 #include <comphelper/processfactory.hxx>
66 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
67 #include <svx/dialmgr.hxx>
68 #include <svx/dialogs.hrc>
69 
70 #include <algorithm>
71 #include <vector>
72 #include "sfx2/opengrf.hxx"
73 
74 #include <cuires.hrc> //CHINA001
75 #include <sfx2/request.hxx> //CHINA001
76 #include <svl/aeitem.hxx> //add CHINA001
77 #include <svl/stritem.hxx>//add CHINA001
78 #include <svl/slstitm.hxx> //add CHINA001
79 
80 using namespace com::sun::star;
81 using namespace com::sun::star::uno;
82 using namespace com::sun::star::beans;
83 using namespace com::sun::star::lang;
84 using namespace com::sun::star::i18n;
85 using namespace com::sun::star::text;
86 using namespace com::sun::star::container;
87 using namespace com::sun::star::style;
88 using rtl::OUString;
89 #define C2U(cChar) OUString::createFromAscii(cChar)
90 
91 SV_IMPL_PTRARR(SvxNumSettingsArr_Impl,SvxNumSettings_ImplPtr);
92 
93 /*-----------------07.02.97 15.37-------------------
94 
95 --------------------------------------------------*/
96 #define NUM_PAGETYPE_BULLET			0
97 #define NUM_PAGETYPE_SINGLENUM      1
98 #define NUM_PAGETYPE_NUM            2
99 #define NUM_PAGETYPE_BMP            3
100 #define PAGETYPE_USER_START         10
101 
102 #define SHOW_NUMBERING				0
103 #define SHOW_BULLET					1
104 #define SHOW_BITMAP					2
105 
106 #define MAX_BMP_WIDTH				16
107 #define MAX_BMP_HEIGHT				16
108 
109 static sal_Bool bLastRelative =			sal_False;
110 static const sal_Char cNumberingType[] = "NumberingType";
111 static const sal_Char cValue[] = "Value";
112 static const sal_Char cParentNumbering[] = "ParentNumbering";
113 static const sal_Char cPrefix[] = "Prefix";
114 static const sal_Char cSuffix[] = "Suffix";
115 static const sal_Char cBulletChar[] = "BulletChar";
116 static const sal_Char cBulletFontName[] = "BulletFontName";
117 /* -----------------------------31.01.01 10:23--------------------------------
118 
119  ---------------------------------------------------------------------------*/
lcl_GetNumberingProvider()120 Reference<XDefaultNumberingProvider> lcl_GetNumberingProvider()
121 {
122 	Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
123 	Reference < XInterface > xI = xMSF->createInstance(
124 		::rtl::OUString::createFromAscii( "com.sun.star.text.DefaultNumberingProvider" ) );
125 	Reference<XDefaultNumberingProvider> xRet(xI, UNO_QUERY);
126 	DBG_ASSERT(xRet.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\"");
127 
128 	return xRet;
129 }
130 /* -----------------------------31.01.01 11:40--------------------------------
131 
132  ---------------------------------------------------------------------------*/
lcl_CreateNumSettingsPtr(const Sequence<PropertyValue> & rLevelProps)133 SvxNumSettings_ImplPtr lcl_CreateNumSettingsPtr(const Sequence<PropertyValue>& rLevelProps)
134 {
135 	const PropertyValue* pValues = rLevelProps.getConstArray();
136 	SvxNumSettings_ImplPtr pNew = new SvxNumSettings_Impl;
137 	for(sal_Int32 j = 0; j < rLevelProps.getLength(); j++)
138 	{
139 		if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cNumberingType)))
140 			pValues[j].Value >>= pNew->nNumberType;
141 		else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cPrefix)))
142 			pValues[j].Value >>= pNew->sPrefix;
143 		else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cSuffix)))
144 			pValues[j].Value >>= pNew->sSuffix;
145 		else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cParentNumbering)))
146 			pValues[j].Value >>= pNew->nParentNumbering;
147 		else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cBulletChar)))
148 			pValues[j].Value >>= pNew->sBulletChar;
149 		else if(pValues[j].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cBulletFontName)))
150 			pValues[j].Value >>= pNew->sBulletFont;
151 	}
152 	return pNew;
153 }
154 /* -----------------28.10.98 08:32-------------------
155  *
156  * --------------------------------------------------*/
157 // Die Auswahl an Bullets aus den StarSymbol
158 static const sal_Unicode aBulletTypes[] =
159 {
160 	0x2022,
161 	0x25cf,
162 	0xe00c,
163 	0xe00a,
164 	0x2794,
165 	0x27a2,
166 	0x2717,
167 	0x2714
168 };
169 /* -----------------28.10.98 09:42-------------------
170  *
171  * --------------------------------------------------*/
172 static sal_Char __READONLY_DATA aNumChar[] =
173 {
174 	'A', //CHARS_UPPER_LETTER
175 	'a', //CHARS_LOWER_LETTER
176 	'I', //ROMAN_UPPER
177 	'i', //ROMAN_LOWER
178 	'1', //ARABIC
179 	' '
180 };
181 
182 /*-----------------18.03.98 08:35-------------------
183 	Ist eins der maskierten Formate gesetzt?
184 --------------------------------------------------*/
lcl_IsNumFmtSet(SvxNumRule * pNum,sal_uInt16 nLevelMask)185 sal_Bool lcl_IsNumFmtSet(SvxNumRule* pNum, sal_uInt16 nLevelMask)
186 {
187 	sal_Bool bRet = sal_False;
188 	sal_uInt16 nMask = 1;
189 	for( sal_uInt16 i = 0; i < SVX_MAX_NUM && !bRet; i++ )
190 	{
191 		if(nLevelMask & nMask)
192 			bRet |= 0 != pNum->Get( i );
193 		nMask <<= 1 ;
194 	}
195 	return bRet;
196 }
197 /* -----------------28.10.98 08:50-------------------
198  *
199  * --------------------------------------------------*/
200 
lcl_GetDefaultBulletFont()201 Font& lcl_GetDefaultBulletFont()
202 {
203 	static sal_Bool bInit = 0;
204 	static Font aDefBulletFont( UniString::CreateFromAscii(
205 		                        RTL_CONSTASCII_STRINGPARAM( "StarSymbol" ) ),
206 								String(), Size( 0, 14 ) );
207 	if(!bInit)
208 	{
209         aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
210 		aDefBulletFont.SetFamily( FAMILY_DONTKNOW );
211 		aDefBulletFont.SetPitch( PITCH_DONTKNOW );
212 		aDefBulletFont.SetWeight( WEIGHT_DONTKNOW );
213 		aDefBulletFont.SetTransparent( sal_True );
214 		bInit = sal_True;
215 	}
216 	return aDefBulletFont;
217 }
218 
219 
220 /**************************************************************************/
221 /*                                                                        */
222 /*                                                                        */
223 /**************************************************************************/
224 
225 
SvxSingleNumPickTabPage(Window * pParent,const SfxItemSet & rSet)226 SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(Window* pParent,
227 							   const SfxItemSet& rSet)	:
228 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_PICK_SINGLE_NUM ), rSet ),
229     aValuesFL(      this, CUI_RES(FL_VALUES) ),
230 	pExamplesVS(	new SvxNumValueSet(this, CUI_RES(VS_VALUES), NUM_PAGETYPE_SINGLENUM )),
231 	pActNum(0),
232 	pSaveNum(0),
233 	nActNumLvl( USHRT_MAX ),
234 	bModified(sal_False),
235 	bPreset(sal_False),
236 	nNumItemId(SID_ATTR_NUMBERING_RULE)
237 {
238 	FreeResource();
239 	SetExchangeSupport();
240 	pExamplesVS->SetSelectHdl(LINK(this, SvxSingleNumPickTabPage, NumSelectHdl_Impl));
241 	pExamplesVS->SetDoubleClickHdl(LINK(this, SvxSingleNumPickTabPage, DoubleClickHdl_Impl));
242 	pExamplesVS->SetHelpId(HID_VALUESET_SINGLENUM );
243 
244 	Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
245 	if(xDefNum.is())
246 	{
247 		Sequence< Sequence< PropertyValue > > aNumberings;
248         LanguageType eLang = Application::GetSettings().GetLanguage();
249 		Locale aLocale = SvxCreateLocale(eLang);
250 		try
251 		{
252 			aNumberings =
253 				xDefNum->getDefaultContinuousNumberingLevels( aLocale );
254 
255 
256             sal_Int32 nLength = aNumberings.getLength() > NUM_VALUSET_COUNT ? NUM_VALUSET_COUNT :aNumberings.getLength();
257 
258 			const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray();
259 			for(sal_Int32 i = 0; i < nLength; i++)
260 			{
261 				SvxNumSettings_ImplPtr pNew = lcl_CreateNumSettingsPtr(pValuesArr[i]);
262 				aNumSettingsArr.Insert(pNew, aNumSettingsArr.Count());
263 			}
264 		}
265 		catch(Exception&)
266 		{
267 		}
268 		Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
269 		pExamplesVS->SetNumberingSettings(aNumberings, xFormat, aLocale);
270 	}
271 }
272 /*-----------------07.02.97 12.08-------------------
273 
274 --------------------------------------------------*/
275 
~SvxSingleNumPickTabPage()276  SvxSingleNumPickTabPage::~SvxSingleNumPickTabPage()
277 {
278 	delete pActNum;
279 	delete pExamplesVS;
280 	delete pSaveNum;
281 	aNumSettingsArr.DeleteAndDestroy(0, aNumSettingsArr.Count());
282 }
283 
284 /*-----------------07.02.97 12.13-------------------
285 
286 --------------------------------------------------*/
287 
Create(Window * pParent,const SfxItemSet & rAttrSet)288 SfxTabPage*	 SvxSingleNumPickTabPage::Create( Window* pParent,
289 								const SfxItemSet& rAttrSet)
290 {
291 	return new SvxSingleNumPickTabPage(pParent, rAttrSet);
292 }
293 
294 /*-----------------07.02.97 12.09-------------------
295 
296 --------------------------------------------------*/
297 
298 
FillItemSet(SfxItemSet & rSet)299 sal_Bool  SvxSingleNumPickTabPage::FillItemSet( SfxItemSet& rSet )
300 {
301 	if( (bPreset || bModified) && pSaveNum)
302 	{
303 		*pSaveNum = *pActNum;
304 		rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
305 		rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
306 	}
307 
308 	return bModified;
309 }
310 
311 /*-----------------08.02.97 16.27-------------------
312 
313 --------------------------------------------------*/
314 
ActivatePage(const SfxItemSet & rSet)315 void  SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
316 {
317 	const SfxPoolItem* pItem;
318 	bPreset = sal_False;
319 	sal_Bool bIsPreset = sal_False;
320 	const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
321 	if(pExampleSet)
322 	{
323 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
324 			bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
325 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
326 			nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
327 	}
328 	if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
329 	{
330 		delete pSaveNum;
331 		pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
332 	}
333 	if(*pSaveNum != *pActNum)
334 	{
335 		*pActNum = *pSaveNum;
336 		pExamplesVS->SetNoSelection();
337 	}
338 	// ersten Eintrag vorselektieren
339 	if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
340 	{
341 		pExamplesVS->SelectItem(1);
342 		NumSelectHdl_Impl(pExamplesVS);
343 		bPreset = sal_True;
344 	}
345 	bPreset |= bIsPreset;
346 
347 	bModified = sal_False;
348 }
349 
350 /*-----------------08.02.97 11.28-------------------
351 
352 --------------------------------------------------*/
353 
DeactivatePage(SfxItemSet * _pSet)354 int  SvxSingleNumPickTabPage::DeactivatePage(SfxItemSet *_pSet)
355 {
356 	if(_pSet)
357 		FillItemSet(*_pSet);
358 	return sal_True;
359 }
360 
361 /*-----------------07.02.97 12.09-------------------
362 
363 --------------------------------------------------*/
364 
365 
Reset(const SfxItemSet & rSet)366 void  SvxSingleNumPickTabPage::Reset( const SfxItemSet& rSet )
367 {
368 	const SfxPoolItem* pItem;
369 //	nActNumLvl = ((SwNumBulletTabDialog*)GetTabDialog())->GetActNumLevel();
370 	//im Draw gibt es das Item als WhichId, im Writer nur als SlotId
371 	SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
372 	if(eState != SFX_ITEM_SET)
373 	{
374 		nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
375 		eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
376 
377 		if( eState != SFX_ITEM_SET )
378 		{
379 	        pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
380 	        eState = SFX_ITEM_SET;
381 		}
382 	}
383 	DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
384 	delete pSaveNum;
385 	pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
386 
387 	if(!pActNum)
388 		pActNum = new  SvxNumRule(*pSaveNum);
389 	else if(*pSaveNum != *pActNum)
390 		*pActNum = *pSaveNum;
391 }
392 /*-----------------08.02.97 11.40-------------------
393 
394 --------------------------------------------------*/
395 
IMPL_LINK(SvxSingleNumPickTabPage,NumSelectHdl_Impl,ValueSet *,EMPTYARG)396 IMPL_LINK(SvxSingleNumPickTabPage, NumSelectHdl_Impl, ValueSet*, EMPTYARG)
397 {
398 	if(pActNum)
399 	{
400 		bPreset = sal_False;
401 		bModified = sal_True;
402 		sal_uInt16 nIdx = pExamplesVS->GetSelectItemId() - 1;
403 		DBG_ASSERT(aNumSettingsArr.Count() > nIdx, "wrong index");
404 		if(aNumSettingsArr.Count() <= nIdx)
405 			return 0;
406 		SvxNumSettings_ImplPtr _pSet = aNumSettingsArr.GetObject(nIdx);
407 		sal_Int16 eNewType = _pSet->nNumberType;
408         const sal_Unicode cLocalPrefix = _pSet->sPrefix.getLength() ? _pSet->sPrefix.getStr()[0] : 0;
409         const sal_Unicode cLocalSuffix = _pSet->sSuffix.getLength() ? _pSet->sSuffix.getStr()[0] : 0;
410 
411 		sal_uInt16 nMask = 1;
412 		for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
413 		{
414 			if(nActNumLvl & nMask)
415 			{
416 				SvxNumberFormat aFmt(pActNum->GetLevel(i));
417 				aFmt.SetNumberingType(eNewType);
418 				String aEmptyStr;
419 				if(cLocalPrefix == ' ')
420 					aFmt.SetPrefix( aEmptyStr );
421 				else
422                     aFmt.SetPrefix(_pSet->sPrefix);
423 				if(cLocalSuffix == ' ')
424 					aFmt.SetSuffix( aEmptyStr );
425 				else
426                     aFmt.SetSuffix(_pSet->sSuffix);
427 				aFmt.SetCharFmtName(sNumCharFmtName);
428                 // #62069# // #92724#
429                 aFmt.SetBulletRelSize(100);
430                 pActNum->SetLevel(i, aFmt);
431 			}
432 			nMask <<= 1 ;
433 		}
434 	}
435 	return 0;
436 }
437 
438 /*-----------------06.06.97 11.15-------------------
439 
440 --------------------------------------------------*/
IMPL_LINK(SvxSingleNumPickTabPage,DoubleClickHdl_Impl,ValueSet *,EMPTYARG)441 IMPL_LINK(SvxSingleNumPickTabPage, DoubleClickHdl_Impl, ValueSet*, EMPTYARG)
442 {
443 	NumSelectHdl_Impl(pExamplesVS);
444 	OKButton& rOk = GetTabDialog()->GetOKButton();
445 	rOk.GetClickHdl().Call(&rOk);
446 	return 0;
447 }
448 
449 /**************************************************************************/
450 /*                                                                        */
451 /*                                                                        */
452 /**************************************************************************/
453 
454 
SvxBulletPickTabPage(Window * pParent,const SfxItemSet & rSet)455 SvxBulletPickTabPage::SvxBulletPickTabPage(Window* pParent,
456 							   const SfxItemSet& rSet)	:
457 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_PICK_BULLET ), rSet ),
458     aValuesFL(      this, CUI_RES(FL_VALUES) ),
459 	pExamplesVS(	new SvxNumValueSet(this, CUI_RES(VS_VALUES), NUM_PAGETYPE_BULLET )),
460 	pActNum(0),
461 	pSaveNum(0),
462 	nActNumLvl( USHRT_MAX ),
463 	bModified(sal_False),
464 	bPreset(sal_False),
465 	nNumItemId(SID_ATTR_NUMBERING_RULE)
466 {
467 	FreeResource();
468 	SetExchangeSupport();
469 	pExamplesVS->SetSelectHdl(LINK(this, SvxBulletPickTabPage, NumSelectHdl_Impl));
470 	pExamplesVS->SetDoubleClickHdl(LINK(this, SvxBulletPickTabPage, DoubleClickHdl_Impl));
471 	pExamplesVS->SetHelpId(HID_VALUESET_BULLET    );
472 
473 }
474 /*-----------------07.02.97 12.10-------------------
475 
476 --------------------------------------------------*/
477 
478 
~SvxBulletPickTabPage()479  SvxBulletPickTabPage::~SvxBulletPickTabPage()
480 {
481 	delete pActNum;
482 	delete pExamplesVS;
483 	delete pSaveNum;
484 }
485 /*-----------------07.02.97 12.10-------------------
486 
487 --------------------------------------------------*/
488 
489 
Create(Window * pParent,const SfxItemSet & rAttrSet)490 SfxTabPage*	 SvxBulletPickTabPage::Create( Window* pParent,
491 								const SfxItemSet& rAttrSet)
492 {
493 	return new SvxBulletPickTabPage(pParent, rAttrSet);
494 }
495 
496 /*-----------------07.02.97 12.10-------------------
497 
498 --------------------------------------------------*/
499 
500 
FillItemSet(SfxItemSet & rSet)501 sal_Bool  SvxBulletPickTabPage::FillItemSet( SfxItemSet& rSet )
502 {
503 	if( (bPreset || bModified) && pActNum)
504 	{
505 		*pSaveNum = *pActNum;
506 		rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
507 		rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
508 	}
509 	return bModified;
510 }
511 /*-----------------08.02.97 16.28-------------------
512 
513 --------------------------------------------------*/
514 
ActivatePage(const SfxItemSet & rSet)515 void  SvxBulletPickTabPage::ActivatePage(const SfxItemSet& rSet)
516 {
517 	const SfxPoolItem* pItem;
518 	bPreset = sal_False;
519 	sal_Bool bIsPreset = sal_False;
520 	const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
521 	if(pExampleSet)
522 	{
523 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
524 			bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
525 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
526 			nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
527 	}
528 	if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
529 	{
530 		delete pSaveNum;
531 		pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
532 	}
533 	if(*pSaveNum != *pActNum)
534 	{
535 		*pActNum = *pSaveNum;
536 		pExamplesVS->SetNoSelection();
537 	}
538 	// ersten Eintrag vorselektieren
539 	if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
540 	{
541 		pExamplesVS->SelectItem(1);
542 		NumSelectHdl_Impl(pExamplesVS);
543 		bPreset = sal_True;
544 	}
545 	bPreset |= bIsPreset;
546 	bModified = sal_False;
547 }
548 /*-----------------08.02.97 11.28-------------------
549 
550 --------------------------------------------------*/
551 
DeactivatePage(SfxItemSet * _pSet)552 int  SvxBulletPickTabPage::DeactivatePage(SfxItemSet *_pSet)
553 {
554 	if(_pSet)
555 		FillItemSet(*_pSet);
556 	return sal_True;
557 }
558 
559 /*-----------------07.02.97 12.11-------------------
560 
561 --------------------------------------------------*/
562 
563 
Reset(const SfxItemSet & rSet)564 void  SvxBulletPickTabPage::Reset( const SfxItemSet& rSet )
565 {
566 	const SfxPoolItem* pItem;
567 	//im Draw gibt es das Item als WhichId, im Writer nur als SlotId
568 	SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
569 	if(eState != SFX_ITEM_SET)
570 	{
571 		nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
572 		eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
573 
574 		if( eState != SFX_ITEM_SET )
575 		{
576 	        pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
577 	        eState = SFX_ITEM_SET;
578 		}
579 
580 	}
581 	DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
582 	delete pSaveNum;
583 	pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
584 
585 //	nActNumLvl = ((SwNumBulletTabDialog*)GetTabDialog())->GetActNumLevel();
586 
587 	if(!pActNum)
588 		pActNum = new  SvxNumRule(*pSaveNum);
589 	else if(*pSaveNum != *pActNum)
590 		*pActNum = *pSaveNum;
591 }
592 /*-----------------08.02.97 11.58-------------------
593 
594 --------------------------------------------------*/
595 
IMPL_LINK(SvxBulletPickTabPage,NumSelectHdl_Impl,ValueSet *,EMPTYARG)596 IMPL_LINK(SvxBulletPickTabPage, NumSelectHdl_Impl, ValueSet*, EMPTYARG)
597 {
598 	if(pActNum)
599 	{
600 		bPreset = sal_False;
601 		bModified = sal_True;
602 		sal_Unicode cChar = aBulletTypes[pExamplesVS->GetSelectItemId() - 1];
603 		Font& rActBulletFont = lcl_GetDefaultBulletFont();
604 
605 		sal_uInt16 nMask = 1;
606 		for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
607 		{
608 			if(nActNumLvl & nMask)
609 			{
610 				SvxNumberFormat aFmt(pActNum->GetLevel(i));
611 				aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
612                 // #i93908# clear suffix for bullet lists
613                 aFmt.SetPrefix(::rtl::OUString());
614                 aFmt.SetSuffix(::rtl::OUString());
615 				aFmt.SetBulletFont(&rActBulletFont);
616 				aFmt.SetBulletChar(cChar );
617 				aFmt.SetCharFmtName(sBulletCharFmtName);
618                 // #62069# // #92724#
619                 aFmt.SetBulletRelSize(45);
620 				pActNum->SetLevel(i, aFmt);
621 			}
622 			nMask <<= 1;
623 		}
624 	}
625 
626 	return 0;
627 }
628 
629 /*-----------------06.06.97 11.16-------------------
630 
631 --------------------------------------------------*/
IMPL_LINK(SvxBulletPickTabPage,DoubleClickHdl_Impl,ValueSet *,EMPTYARG)632 IMPL_LINK(SvxBulletPickTabPage, DoubleClickHdl_Impl, ValueSet*, EMPTYARG)
633 {
634 	NumSelectHdl_Impl(pExamplesVS);
635 	OKButton& rOk = GetTabDialog()->GetOKButton();
636 	rOk.GetClickHdl().Call(&rOk);
637 	return 0;
638 }
639 
640 //Add CHINA001
PageCreated(SfxAllItemSet aSet)641 void SvxBulletPickTabPage::PageCreated(SfxAllItemSet aSet)
642 {
643 
644 	SFX_ITEMSET_ARG	(&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,sal_False);
645 
646 	if (pBulletCharFmt)
647 		SetCharFmtName( pBulletCharFmt->GetValue());
648 
649 
650 }
651 //end of add CHINA001
652 /**************************************************************************/
653 /*                                                                        */
654 /*                                                                        */
655 /**************************************************************************/
656 
657 
SvxNumPickTabPage(Window * pParent,const SfxItemSet & rSet)658 SvxNumPickTabPage::SvxNumPickTabPage(Window* pParent,
659 							   const SfxItemSet& rSet) :
660 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_PICK_NUM ), rSet ),
661     aValuesFL(      this, CUI_RES(FL_VALUES) ),
662 	pExamplesVS(	new SvxNumValueSet(this, CUI_RES(VS_VALUES), NUM_PAGETYPE_NUM )),
663 	pActNum(0),
664 	pSaveNum(0),
665 	nActNumLvl( USHRT_MAX ),
666 	nNumItemId(SID_ATTR_NUMBERING_RULE),
667 	bModified(sal_False),
668 	bPreset(sal_False)
669 {
670 
671 	FreeResource();
672 
673 	SetExchangeSupport();
674 
675 	pExamplesVS->SetSelectHdl(LINK(this, SvxNumPickTabPage, NumSelectHdl_Impl));
676 	pExamplesVS->SetDoubleClickHdl(LINK(this, SvxNumPickTabPage, DoubleClickHdl_Impl));
677 	pExamplesVS->SetHelpId(HID_VALUESET_NUM       );
678 
679 	Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
680 	if(xDefNum.is())
681 	{
682 		Sequence<Reference<XIndexAccess> > aOutlineAccess;
683         LanguageType eLang = Application::GetSettings().GetLanguage();
684 		Locale aLocale = SvxCreateLocale(eLang);
685 		try
686 		{
687 			aOutlineAccess = xDefNum->getDefaultOutlineNumberings( aLocale );
688 
689 			for(sal_Int32 nItem = 0;
690 				nItem < aOutlineAccess.getLength() && nItem < NUM_VALUSET_COUNT;
691 				nItem++ )
692 			{
693 				SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[ nItem ];
694 
695 				Reference<XIndexAccess> xLevel = aOutlineAccess.getConstArray()[nItem];
696 				for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++)
697 				{
698 					Any aValueAny = xLevel->getByIndex(nLevel);
699 					Sequence<PropertyValue> aLevelProps;
700 					aValueAny >>= aLevelProps;
701 					SvxNumSettings_ImplPtr pNew = lcl_CreateNumSettingsPtr(aLevelProps);
702 					rItemArr.Insert( pNew, rItemArr.Count() );
703 				}
704 			}
705 		}
706 		catch(Exception&)
707 		{
708 		}
709 		Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
710 		pExamplesVS->SetOutlineNumberingSettings(aOutlineAccess, xFormat, aLocale);
711 	}
712 }
713 /*-----------------07.02.97 12.12-------------------
714 
715 --------------------------------------------------*/
716 
717 
~SvxNumPickTabPage()718  SvxNumPickTabPage::~SvxNumPickTabPage()
719 {
720 	delete pActNum;
721 	delete pExamplesVS;
722 	delete pSaveNum;
723 }
724 
725 /*-----------------07.02.97 12.12-------------------
726 
727 --------------------------------------------------*/
728 
729 
Create(Window * pParent,const SfxItemSet & rAttrSet)730 SfxTabPage*	 SvxNumPickTabPage::Create( Window* pParent,
731 								const SfxItemSet& rAttrSet)
732 {
733 	return new SvxNumPickTabPage(pParent, rAttrSet);
734 }
735 
736 /*-----------------07.02.97 12.12-------------------
737 
738 --------------------------------------------------*/
739 
740 
FillItemSet(SfxItemSet & rSet)741 sal_Bool  SvxNumPickTabPage::FillItemSet( SfxItemSet& rSet )
742 {
743 	if( (bPreset || bModified) && pActNum)
744 	{
745 		*pSaveNum = *pActNum;
746 		rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
747 		rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
748 	}
749 	return bModified;
750 }
751 /*-----------------08.02.97 16.28-------------------
752 
753 --------------------------------------------------*/
754 
ActivatePage(const SfxItemSet & rSet)755 void  SvxNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
756 {
757 	const SfxPoolItem* pItem;
758 	bPreset = sal_False;
759 	sal_Bool bIsPreset = sal_False;
760 	const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
761 	if(pExampleSet)
762 	{
763 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
764 			bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
765 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
766 			nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
767 	}
768 	if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
769 	{
770 		delete pSaveNum;
771 		pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
772 	}
773 	if(*pSaveNum != *pActNum)
774 	{
775 		*pActNum = *pSaveNum;
776 		pExamplesVS->SetNoSelection();
777 	}
778 	// ersten Eintrag vorselektieren
779 	if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
780 	{
781 		pExamplesVS->SelectItem(1);
782 		NumSelectHdl_Impl(pExamplesVS);
783 		bPreset = sal_True;
784 	}
785 	bPreset |= bIsPreset;
786 	bModified = sal_False;
787 }
788 
789 /* -----------------08.02.97 11.29-------------------
790 
791 --------------------------------------------------*/
792 
DeactivatePage(SfxItemSet * _pSet)793 int  SvxNumPickTabPage::DeactivatePage(SfxItemSet *_pSet)
794 {
795 	if(_pSet)
796 		FillItemSet(*_pSet);
797 	return sal_True;
798 }
799 
800 /*-----------------07.02.97 12.12-------------------
801 
802 --------------------------------------------------*/
803 
Reset(const SfxItemSet & rSet)804 void  SvxNumPickTabPage::Reset( const SfxItemSet& rSet )
805 {
806 	const SfxPoolItem* pItem;
807 	//im Draw gibt es das Item als WhichId, im Writer nur als SlotId
808 	SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
809 	if(eState != SFX_ITEM_SET)
810 	{
811 		nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
812 		eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
813 
814 		if( eState != SFX_ITEM_SET )
815 		{
816 	        pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
817 	        eState = SFX_ITEM_SET;
818 		}
819 
820 	}
821 	DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
822 	delete pSaveNum;
823 	pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
824 
825 //	nActNumLvl = ((SwNumBulletTabDialog*)GetTabDialog())->GetActNumLevel();
826 	if(!pActNum)
827 		pActNum = new  SvxNumRule(*pSaveNum);
828 	else if(*pSaveNum != *pActNum)
829 		*pActNum = *pSaveNum;
830 
831 }
832 
833 /*-----------------08.02.97 11.58-------------------
834 	Hier werden alle Ebenen veraendert,
835 --------------------------------------------------*/
836 
IMPL_LINK(SvxNumPickTabPage,NumSelectHdl_Impl,ValueSet *,EMPTYARG)837 IMPL_LINK(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, EMPTYARG)
838 {
839 	if(pActNum)
840 	{
841 		bPreset = sal_False;
842 		bModified = sal_True;
843 
844         const FontList*  pList = 0;
845 
846         SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[pExamplesVS->GetSelectItemId() - 1];
847 
848 		Font& rActBulletFont = lcl_GetDefaultBulletFont();
849 		SvxNumSettings_ImplPtr pLevelSettings = 0;
850 		for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
851 		{
852 			if(rItemArr.Count() > i)
853 				pLevelSettings = rItemArr[i];
854 			if(!pLevelSettings)
855 				break;
856 			SvxNumberFormat aFmt(pActNum->GetLevel(i));
857 			aFmt.SetNumberingType( pLevelSettings->nNumberType );
858 			sal_uInt16 nUpperLevelOrChar = (sal_uInt16)pLevelSettings->nParentNumbering;
859 			if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL)
860 			{
861                 // #i93908# clear suffix for bullet lists
862                 aFmt.SetPrefix(::rtl::OUString());
863                 aFmt.SetSuffix(::rtl::OUString());
864 				if( pLevelSettings->sBulletFont.getLength() &&
865 					pLevelSettings->sBulletFont.compareTo(
866 							rActBulletFont.GetName()))
867 				{
868                     //search for the font
869                     if(!pList)
870                     {
871                         SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
872                         const SvxFontListItem* pFontListItem =
873                                 (const SvxFontListItem* )pCurDocShell
874 													->GetItem( SID_ATTR_CHAR_FONTLIST );
875                         pList = pFontListItem ? pFontListItem->GetFontList() : 0;
876                     }
877                     if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) )
878                     {
879 						FontInfo aInfo = pList->Get(
880                             pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE);
881 						Font aFont(aInfo);
882 						aFmt.SetBulletFont(&aFont);
883                     }
884                     else
885                     {
886                         //if it cannot be found then create a new one
887                         Font aCreateFont( pLevelSettings->sBulletFont,
888                                                 String(), Size( 0, 14 ) );
889                         aCreateFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW );
890                         aCreateFont.SetFamily( FAMILY_DONTKNOW );
891                         aCreateFont.SetPitch( PITCH_DONTKNOW );
892                         aCreateFont.SetWeight( WEIGHT_DONTKNOW );
893                         aCreateFont.SetTransparent( sal_True );
894                         aFmt.SetBulletFont( &aCreateFont );
895                     }
896 				}
897 				else
898                     aFmt.SetBulletFont( &rActBulletFont );
899 
900 				aFmt.SetBulletChar( pLevelSettings->sBulletChar.getLength()
901 										? pLevelSettings->sBulletChar.getStr()[0]
902 										: 0 );
903 				aFmt.SetCharFmtName( sBulletCharFmtName );
904                 // #62069# // #92724#
905                 aFmt.SetBulletRelSize(45);
906             }
907 			else
908 			{
909 				aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? pActNum->GetLevelCount() : 0));
910 				aFmt.SetCharFmtName(sNumCharFmtName);
911                 // #62069# // #92724#
912                 aFmt.SetBulletRelSize(100);
913                 // #i93908#
914                 aFmt.SetPrefix(pLevelSettings->sPrefix);
915                 aFmt.SetSuffix(pLevelSettings->sSuffix);
916             }
917 			pActNum->SetLevel(i, aFmt);
918 		}
919 	}
920 	return 0;
921 }
922 
923 /*-----------------06.06.97 11.16-------------------
924 
925 --------------------------------------------------*/
IMPL_LINK(SvxNumPickTabPage,DoubleClickHdl_Impl,ValueSet *,EMPTYARG)926 IMPL_LINK(SvxNumPickTabPage, DoubleClickHdl_Impl, ValueSet*, EMPTYARG)
927 {
928 	NumSelectHdl_Impl(pExamplesVS);
929 	OKButton& rOk = GetTabDialog()->GetOKButton();
930 	rOk.GetClickHdl().Call(&rOk);
931 	return 0;
932 }
933 
934 //add CHINA001 begin
PageCreated(SfxAllItemSet aSet)935 void SvxNumPickTabPage::PageCreated(SfxAllItemSet aSet)
936 {
937 	SFX_ITEMSET_ARG	(&aSet,pNumCharFmt,SfxStringItem,SID_NUM_CHAR_FMT,sal_False);
938 	SFX_ITEMSET_ARG	(&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,sal_False);
939 
940 
941 	if (pNumCharFmt &&pBulletCharFmt)
942 		SetCharFmtNames( pNumCharFmt->GetValue(),pBulletCharFmt->GetValue());
943 }
944 //end of CHINA001
945 
946 /**************************************************************************/
947 /*                                                                        */
948 /*                                                                        */
949 /**************************************************************************/
950 
SvxBitmapPickTabPage(Window * pParent,const SfxItemSet & rSet)951 SvxBitmapPickTabPage::SvxBitmapPickTabPage(Window* pParent,
952 							   const SfxItemSet& rSet) :
953 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_PICK_BMP ), rSet ),
954     aValuesFL(      this, CUI_RES(FL_VALUES) ),
955     pExamplesVS(    new SvxBmpNumValueSet(this, CUI_RES(VS_VALUES)/*, aGrfNames*/ )),
956 	aErrorText(		this, CUI_RES(FT_ERROR)),
957 	aLinkedCB(		this, CUI_RES(CB_LINKED)),
958 	pActNum(0),
959 	pSaveNum(0),
960 	nActNumLvl( USHRT_MAX ),
961 	nNumItemId(SID_ATTR_NUMBERING_RULE),
962 	bModified(sal_False),
963 	bPreset(sal_False)
964 {
965 	FreeResource();
966 	SetExchangeSupport();
967 	eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
968 	pExamplesVS->SetSelectHdl(LINK(this, SvxBitmapPickTabPage, NumSelectHdl_Impl));
969 	pExamplesVS->SetDoubleClickHdl(LINK(this, SvxBitmapPickTabPage, DoubleClickHdl_Impl));
970 	aLinkedCB.SetClickHdl(LINK(this, SvxBitmapPickTabPage, LinkBmpHdl_Impl));
971 
972 	// Grafiknamen ermitteln
973 
974 	GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames);
975 	pExamplesVS->SetHelpId(HID_VALUESET_NUMBMP    );
976 	for(sal_uInt16 i = 0; i < aGrfNames.Count(); i++)
977 	{
978 		pExamplesVS->InsertItem( i + 1, i);
979 		String* pGrfNm = (String*) aGrfNames.GetObject(i);
980         INetURLObject aObj(*pGrfNm);
981         if(aObj.GetProtocol() == INET_PROT_FILE)
982             *pGrfNm = aObj.PathToFileName();
983 		pExamplesVS->SetItemText( i + 1, *pGrfNm );
984 	}
985 	if(!aGrfNames.Count())
986 	{
987 		aErrorText.Show();
988 	}
989 	else
990 	{
991 		pExamplesVS->Show();
992 		pExamplesVS->Format();
993 	}
994 
995 	pExamplesVS->SetAccessibleRelationMemberOf( &aValuesFL );
996 }
997 
998 /*-----------------12.02.97 07.46-------------------
999 
1000 --------------------------------------------------*/
1001 
~SvxBitmapPickTabPage()1002  SvxBitmapPickTabPage::~SvxBitmapPickTabPage()
1003 {
1004 	String* pStr = (String*)aGrfNames.First();
1005 	while( pStr )
1006 	{
1007 		delete pStr;
1008 		pStr = (String*)aGrfNames.Next();
1009 	}
1010 	delete pExamplesVS;
1011 	delete pActNum;
1012 	delete pSaveNum;
1013 }
1014 
1015 /*-----------------12.02.97 07.46-------------------
1016 
1017 --------------------------------------------------*/
1018 
Create(Window * pParent,const SfxItemSet & rAttrSet)1019 SfxTabPage*	 SvxBitmapPickTabPage::Create( Window* pParent,
1020 								const SfxItemSet& rAttrSet)
1021 {
1022 	return new SvxBitmapPickTabPage(pParent, rAttrSet);
1023 }
1024 
1025 /*-----------------12.02.97 07.46-------------------
1026 
1027 --------------------------------------------------*/
1028 
ActivatePage(const SfxItemSet & rSet)1029 void  SvxBitmapPickTabPage::ActivatePage(const SfxItemSet& rSet)
1030 {
1031 	const SfxPoolItem* pItem;
1032 	bPreset = sal_False;
1033 	sal_Bool bIsPreset = sal_False;
1034 //	nActNumLvl = ((SwNumBulletTabDialog*)GetTabDialog())->GetActNumLevel();
1035 	const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
1036 	if(pExampleSet)
1037 	{
1038 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
1039 			bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
1040 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
1041 			nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
1042 	}
1043 	if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
1044 	{
1045 		delete pSaveNum;
1046 		pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
1047 	}
1048 	if(*pSaveNum != *pActNum)
1049 	{
1050 		*pActNum = *pSaveNum;
1051 		pExamplesVS->SetNoSelection();
1052 	}
1053 	// ersten Eintrag vorselektieren
1054 	if(aGrfNames.Count() &&
1055 		(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset)))
1056 	{
1057 		pExamplesVS->SelectItem(1);
1058 		NumSelectHdl_Impl(pExamplesVS);
1059 		bPreset = sal_True;
1060 	}
1061 	bPreset |= bIsPreset;
1062 	bModified = sal_False;
1063 }
1064 /*-----------------12.02.97 07.46-------------------
1065 
1066 --------------------------------------------------*/
1067 
DeactivatePage(SfxItemSet * _pSet)1068 int  SvxBitmapPickTabPage::DeactivatePage(SfxItemSet *_pSet)
1069 {
1070 	if(_pSet)
1071 		FillItemSet(*_pSet);
1072 	return sal_True;
1073 }
1074 /*-----------------12.02.97 07.46-------------------
1075 
1076 --------------------------------------------------*/
1077 
FillItemSet(SfxItemSet & rSet)1078 sal_Bool  SvxBitmapPickTabPage::FillItemSet( SfxItemSet& rSet )
1079 {
1080 	if ( !aGrfNames.Count() )
1081 	{
1082 // das ist im SfxItemSet leider nicht zulaessig #52134#
1083 //		rSet.DisableItem(SID_ATTR_NUMBERING_RULE);
1084 		return sal_False;
1085 	}
1086 	if( (bPreset || bModified) && pActNum)
1087 	{
1088 		*pSaveNum = *pActNum;
1089 		rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
1090 		rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
1091 	}
1092 
1093 	return bModified;
1094 }
1095 /*-----------------12.02.97 07.46-------------------
1096 
1097 --------------------------------------------------*/
1098 
Reset(const SfxItemSet & rSet)1099 void  SvxBitmapPickTabPage::Reset( const SfxItemSet& rSet )
1100 {
1101 	const SfxPoolItem* pItem;
1102 	//im Draw gibt es das Item als WhichId, im Writer nur als SlotId
1103 	SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
1104 	if(eState != SFX_ITEM_SET)
1105 	{
1106 		nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
1107 		eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
1108 
1109 		if( eState != SFX_ITEM_SET )
1110 		{
1111 	        pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
1112 	        eState = SFX_ITEM_SET;
1113 		}
1114 
1115 	}
1116 	DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
1117 	delete pSaveNum;
1118 	pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
1119 
1120 	if(!pActNum)
1121 		pActNum = new  SvxNumRule(*pSaveNum);
1122 	else if(*pSaveNum != *pActNum)
1123 		*pActNum = *pSaveNum;
1124 	if(!pActNum->IsFeatureSupported(NUM_ENABLE_LINKED_BMP))
1125 	{
1126 		aLinkedCB.Check(sal_False);
1127 		aLinkedCB.Enable(sal_False);
1128 	}
1129 	else if(!pActNum->IsFeatureSupported(NUM_ENABLE_EMBEDDED_BMP))
1130 	{
1131 		aLinkedCB.Check(sal_True);
1132 		aLinkedCB.Enable(sal_False);
1133 	}
1134 }
1135 
1136 /*-----------------12.02.97 07.53-------------------
1137 
1138 --------------------------------------------------*/
1139 
IMPL_LINK(SvxBitmapPickTabPage,NumSelectHdl_Impl,ValueSet *,EMPTYARG)1140 IMPL_LINK(SvxBitmapPickTabPage, NumSelectHdl_Impl, ValueSet*, EMPTYARG)
1141 {
1142 	if(pActNum)
1143 	{
1144 		bPreset = sal_False;
1145 		bModified = sal_True;
1146 		sal_uInt16 nIdx = pExamplesVS->GetSelectItemId() - 1;
1147 
1148 		String* pGrfName = 0;
1149 		if(aGrfNames.Count() > nIdx)
1150 			pGrfName = (String*)aGrfNames.GetObject(nIdx);
1151 
1152 		sal_uInt16 nMask = 1;
1153 		String aEmptyStr;
1154 		sal_uInt16 nSetNumberingType = SVX_NUM_BITMAP;
1155 		if(aLinkedCB.IsChecked())
1156 			nSetNumberingType |= LINK_TOKEN;
1157 		for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1158 		{
1159 			if(nActNumLvl & nMask)
1160 			{
1161 				SvxNumberFormat aFmt(pActNum->GetLevel(i));
1162 				aFmt.SetNumberingType(nSetNumberingType);
1163 				aFmt.SetPrefix( aEmptyStr );
1164 				aFmt.SetSuffix( aEmptyStr );
1165 				aFmt.SetCharFmtName( sNumCharFmtName );
1166 
1167                 Graphic aGraphic;
1168                 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nIdx, &aGraphic))
1169 				{
1170                     Size aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
1171                     sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
1172 					aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)eCoreUnit);
1173                     SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH );
1174                     aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
1175 				}
1176 				else if(pGrfName)
1177 					aFmt.SetGraphic( *pGrfName );
1178 				pActNum->SetLevel(i, aFmt);
1179 			}
1180 			nMask <<= 1 ;
1181 		}
1182 	}
1183 
1184 	return 0;
1185 }
1186 
1187 /*-----------------06.06.97 11.17-------------------
1188 
1189 --------------------------------------------------*/
IMPL_LINK(SvxBitmapPickTabPage,DoubleClickHdl_Impl,ValueSet *,EMPTYARG)1190 IMPL_LINK(SvxBitmapPickTabPage, DoubleClickHdl_Impl, ValueSet*, EMPTYARG)
1191 {
1192 	NumSelectHdl_Impl(pExamplesVS);
1193 	OKButton& rOk = GetTabDialog()->GetOKButton();
1194 	rOk.GetClickHdl().Call(&rOk);
1195 	return 0;
1196 }
1197 /* -----------------03.11.99 13:46-------------------
1198 
1199  --------------------------------------------------*/
IMPL_LINK(SvxBitmapPickTabPage,LinkBmpHdl_Impl,CheckBox *,EMPTYARG)1200 IMPL_LINK(SvxBitmapPickTabPage, LinkBmpHdl_Impl, CheckBox*, EMPTYARG )
1201 {
1202 	if(!pExamplesVS->IsNoSelection())
1203 	{
1204 		NumSelectHdl_Impl(pExamplesVS);
1205 	}
1206 	return 0;
1207 }
1208 /*-----------------13.02.97 09.40-------------------
1209 
1210 --------------------------------------------------*/
1211 
1212 //CHINA001 SvxBmpNumValueSet::SvxBmpNumValueSet( Window* pParent, const ResId& rResId/*, const List& rStrNames*/ ) :
1213 //CHINA001
1214 //CHINA001 SvxNumValueSet( pParent, rResId, NUM_PAGETYPE_BMP ),
1215 //CHINA001 //    rStrList    ( rStrNames ),
1216 //CHINA001 bGrfNotFound( sal_False )
1217 //CHINA001
1218 //CHINA001 {
1219 //CHINA001 GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS);
1220 //CHINA001 SetStyle( GetStyle() | WB_VSCROLL );
1221 //CHINA001 SetLineCount( 3 );
1222 //CHINA001 aFormatTimer.SetTimeout(300);
1223 //CHINA001 aFormatTimer.SetTimeoutHdl(LINK(this, SvxBmpNumValueSet, FormatHdl_Impl));
1224 //CHINA001 }
1225 //CHINA001
1226 //CHINA001 /*-----------------13.02.97 09.41-------------------
1227 //CHINA001
1228 //CHINA001 --------------------------------------------------*/
1229 //CHINA001
1230 //CHINA001 SvxBmpNumValueSet::~SvxBmpNumValueSet()
1231 //CHINA001 {
1232 //CHINA001 GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS);
1233 //CHINA001 aFormatTimer.Stop();
1234 //CHINA001 }
1235 //CHINA001 /*-----------------13.02.97 09.41-------------------
1236 //CHINA001
1237 //CHINA001 --------------------------------------------------*/
1238 //CHINA001
1239 //CHINA001 void		SvxBmpNumValueSet::UserDraw( const UserDrawEvent& rUDEvt )
1240 //CHINA001 {
1241 //CHINA001 SvxNumValueSet::UserDraw(rUDEvt);
1242 //CHINA001
1243 //CHINA001 Rectangle aRect = rUDEvt.GetRect();
1244 //CHINA001 OutputDevice*  pDev = rUDEvt.GetDevice();
1245 //CHINA001 sal_uInt16	nItemId = rUDEvt.GetItemId();
1246 //CHINA001 Point aBLPos = aRect.TopLeft();
1247 //CHINA001
1248 //CHINA001 int nRectHeight = aRect.GetHeight();
1249 //CHINA001 Size aSize(nRectHeight/8, nRectHeight/8);
1250 //CHINA001
1251 //CHINA001 Graphic aGraphic;
1252 //CHINA001 if(!GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nItemId - 1,
1253 //CHINA001 &aGraphic, NULL))
1254 //CHINA001 {
1255 //CHINA001 bGrfNotFound = sal_True;
1256 //CHINA001	}
1257 //CHINA001	else
1258 //CHINA001 {
1259 //CHINA001 Point aPos(aBLPos.X() + 5, 0);
1260 //CHINA001 for( sal_uInt16 i = 0; i < 3; i++ )
1261 //CHINA001 {
1262 //CHINA001 sal_uInt16 nY = 11 + i * 33;
1263 //CHINA001 aPos.Y() = aBLPos.Y() + nRectHeight  * nY / 100;
1264 //CHINA001 aGraphic.Draw( pDev, aPos, aSize );
1265 //CHINA001		}
1266 //CHINA001	}
1267 //CHINA001 }
1268 //CHINA001
1269 //CHINA001 /*-----------------14.02.97 07.34-------------------
1270 //CHINA001
1271 //CHINA001 --------------------------------------------------*/
1272 //CHINA001
1273 //CHINA001 IMPL_LINK(SvxBmpNumValueSet, FormatHdl_Impl, Timer*, EMPTYARG)
1274 //CHINA001 {
1275 //CHINA001 // nur, wenn eine Grafik nicht da war, muss formatiert werden
1276 //CHINA001 if(bGrfNotFound)
1277 //CHINA001 {
1278 //CHINA001 bGrfNotFound = sal_False;
1279 //CHINA001 Format();
1280 //CHINA001	}
1281 //CHINA001 Invalidate();
1282 //CHINA001 return 0;
1283 //CHINA001 }
1284 /*-----------------01.12.97 16:15-------------------
1285 	Tabpage Numerierungsoptionen
1286 --------------------------------------------------*/
1287 #define NUM_NO_GRAPHIC 1000
SvxNumOptionsTabPage(Window * pParent,const SfxItemSet & rSet)1288 SvxNumOptionsTabPage::SvxNumOptionsTabPage(Window* pParent,
1289 							   const SfxItemSet& rSet) :
1290 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_NUM_OPTIONS ), rSet ),
1291 
1292     aFormatFL(      this, CUI_RES(FL_FORMAT   )),
1293     aLevelFT(       this, CUI_RES(FT_LEVEL    )),
1294 	aLevelLB(		this, CUI_RES(LB_LEVEL	)),
1295 	aFmtFT(			this, CUI_RES(FT_FMT		)),
1296 	aFmtLB(			this, CUI_RES(LB_FMT		)),
1297 	aPrefixFT(		this, CUI_RES(FT_PREFIX	)),
1298 	aPrefixED(		this, CUI_RES(ED_PREFIX	)),
1299 	aSuffixFT(		this, CUI_RES(FT_SUFFIX	)),
1300 	aSuffixED(		this, CUI_RES(ED_SUFFIX	)),
1301 	aCharFmtFT(		this, CUI_RES(FT_CHARFMT	)),
1302 	aCharFmtLB(		this, CUI_RES(LB_CHARFMT	)),
1303 	aBulColorFT(	this, CUI_RES(FT_BUL_COLOR)),
1304 	aBulColLB(		this, CUI_RES(LB_BUL_COLOR)),
1305 	aBulRelSizeFT(	this, CUI_RES(FT_BUL_REL_SIZE)),
1306 	aBulRelSizeMF(	this, CUI_RES(MF_BUL_REL_SIZE)),
1307 	aAllLevelFT(	this, CUI_RES(FT_ALL_LEVEL)),
1308 	aAllLevelNF(	this, CUI_RES(NF_ALL_LEVEL)),
1309 	aStartFT(		this, CUI_RES(FT_START	)),
1310 	aStartED(		this, CUI_RES(ED_START	)),
1311 	aBulletPB(		this, CUI_RES(PB_BULLET	)),
1312 	aAlignFT(		this, CUI_RES(FT_ALIGN	)),
1313 	aAlignLB(		this, CUI_RES(LB_ALIGN	)),
1314 	aBitmapFT(		this, CUI_RES(FT_BITMAP	)),
1315 	aBitmapMB(		this, CUI_RES(MB_BITMAP	)),
1316 	aSizeFT(		this, CUI_RES(FT_SIZE		)),
1317 	aWidthMF(		this, CUI_RES(MF_WIDTH	)),
1318 	aMultFT(		this, CUI_RES(FT_MULT		)),
1319 	aHeightMF(		this, CUI_RES(MF_HEIGHT	)),
1320 	aRatioCB(		this, CUI_RES(CB_RATIO	)),
1321 	aOrientFT(		this, CUI_RES(FT_ORIENT	)),
1322 	aOrientLB(		this, CUI_RES(LB_ORIENT	)),
1323 	aSameLevelFL(   this, CUI_RES(FL_SAME_LEVEL)),
1324 	aSameLevelCB(	this, CUI_RES(CB_SAME_LEVEL)),
1325 	pPreviewWIN(	new SvxNumberingPreview(this, CUI_RES(WIN_PREVIEW	))),
1326 	pActNum(0),
1327 	pSaveNum(0),
1328 	bLastWidthModified(sal_False),
1329 	bModified(sal_False),
1330 	bPreset(sal_False),
1331 	bAutomaticCharStyles(sal_True),
1332 	bHTMLMode(sal_False),
1333 	bMenuButtonInitialized(sal_False),
1334 	sBullet(CUI_RES(STR_BULLET)),
1335 	nBullet(0xff),
1336 	nActNumLvl(USHRT_MAX),
1337 	nNumItemId(SID_ATTR_NUMBERING_RULE)
1338 {
1339 	sStartWith = aStartFT.GetText();
1340 	pPreviewWIN->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
1341 	SetExchangeSupport();
1342 	aActBulletFont = lcl_GetDefaultBulletFont();
1343 
1344 	aBulletPB.SetClickHdl(LINK(this, SvxNumOptionsTabPage, BulletHdl_Impl));
1345 	aFmtLB.SetSelectHdl(LINK(this, SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl));
1346 	aBitmapMB.SetSelectHdl(LINK(this, SvxNumOptionsTabPage, GraphicHdl_Impl));
1347 	aLevelLB.SetSelectHdl(LINK(this, SvxNumOptionsTabPage, LevelHdl_Impl));
1348 	aCharFmtLB.SetSelectHdl(LINK(this, SvxNumOptionsTabPage, CharFmtHdl_Impl));
1349 	aWidthMF.SetModifyHdl(LINK(this, SvxNumOptionsTabPage, SizeHdl_Impl));
1350 	aHeightMF.SetModifyHdl(LINK(this, SvxNumOptionsTabPage, SizeHdl_Impl));
1351 	aRatioCB.SetClickHdl(LINK(this, SvxNumOptionsTabPage, RatioHdl_Impl));
1352 	aStartED.SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1353 	aPrefixED.SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1354 	aSuffixED.SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1355 	aAllLevelNF.SetModifyHdl(LINK(this,SvxNumOptionsTabPage, AllLevelHdl_Impl));
1356 	aOrientLB.SetSelectHdl(LINK(this, SvxNumOptionsTabPage, OrientHdl_Impl));
1357 	aSameLevelCB.SetClickHdl(LINK(this, SvxNumOptionsTabPage, SameLevelHdl_Impl));
1358 	aBulRelSizeMF.SetModifyHdl(LINK(this,SvxNumOptionsTabPage, BulRelSizeHdl_Impl));
1359 	aBulColLB.SetSelectHdl(LINK(this, SvxNumOptionsTabPage, BulColorHdl_Impl));
1360     aInvalidateTimer.SetTimeoutHdl(LINK(this, SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl));
1361     aInvalidateTimer.SetTimeout(50);
1362 
1363     aBitmapMB.GetPopupMenu()->SetHighlightHdl(LINK(this, SvxNumOptionsTabPage, PopupActivateHdl_Impl));
1364 	PopupMenu* pPopup = new PopupMenu;
1365 	aBitmapMB.GetPopupMenu()->SetPopupMenu( MN_GALLERY, pPopup );
1366 
1367 	pPopup->InsertItem(	NUM_NO_GRAPHIC, String(CUI_RES(ST_POPUP_EMPTY_ENTRY)) );
1368 	pPopup->EnableItem( NUM_NO_GRAPHIC, sal_False );
1369 
1370 	eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
1371 
1372 	aBitmapMB.SetAccessibleRelationLabeledBy( &aBitmapFT );
1373 
1374 	FreeResource();
1375 
1376 	//get advanced numbering types from the component
1377 	Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
1378 	Reference<XNumberingTypeInfo> xInfo(xDefNum, UNO_QUERY);
1379 
1380     // Extended numbering schemes present in the resource but not offered by
1381     // the i18n framework per configuration must be removed from the listbox.
1382     // Watch out for the ugly 0x88/*SVX_NUM_BITMAP|0x80*/ to not remove that.
1383     const sal_uInt16 nDontRemove = 0xffff;
1384     ::std::vector< sal_uInt16> aRemove( aFmtLB.GetEntryCount(), nDontRemove);
1385     for (size_t i=0; i<aRemove.size(); ++i)
1386     {
1387         sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)aFmtLB.GetEntryData(
1388             sal::static_int_cast< sal_uInt16 >(i));
1389         if (nEntryData > NumberingType::CHARS_LOWER_LETTER_N &&
1390                 nEntryData != (SVX_NUM_BITMAP | 0x80))
1391             aRemove[i] = nEntryData;
1392     }
1393 	if(xInfo.is())
1394 	{
1395 		Sequence<sal_Int16> aTypes = xInfo->getSupportedNumberingTypes(  );
1396 		const sal_Int16* pTypes = aTypes.getConstArray();
1397 		for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
1398 		{
1399 			sal_Int16 nCurrent = pTypes[nType];
1400 			if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
1401 			{
1402 				sal_Bool bInsert = sal_True;
1403 				for(sal_uInt16 nEntry = 0; nEntry < aFmtLB.GetEntryCount(); nEntry++)
1404 				{
1405 					sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)aFmtLB.GetEntryData(nEntry);
1406 					if(nEntryData == (sal_uInt16) nCurrent)
1407 					{
1408 						bInsert = sal_False;
1409                         aRemove[nEntry] = nDontRemove;
1410 						break;
1411 					}
1412 				}
1413 				if(bInsert)
1414 				{
1415     				OUString aIdent = xInfo->getNumberingIdentifier( nCurrent );
1416 					sal_uInt16 nPos = aFmtLB.InsertEntry(aIdent);
1417 					aFmtLB.SetEntryData(nPos,(void*)(sal_uLong)nCurrent);
1418 				}
1419 			}
1420 		}
1421 	}
1422     for (size_t i=0; i<aRemove.size(); ++i)
1423     {
1424         if (aRemove[i] != nDontRemove)
1425         {
1426             sal_uInt16 nPos = aFmtLB.GetEntryPos( (void*)(sal_uLong)aRemove[i]);
1427             aFmtLB.RemoveEntry( nPos);
1428         }
1429     }
1430 
1431 	aBulletPB.SetAccessibleRelationMemberOf(&aFormatFL);
1432 	aBulletPB.SetAccessibleRelationLabeledBy(&aStartFT);
1433 	aBulletPB.SetAccessibleName(aStartFT.GetText());
1434 }
1435 
1436 /*-----------------01.12.97 16:30-------------------
1437 
1438 --------------------------------------------------*/
~SvxNumOptionsTabPage()1439 SvxNumOptionsTabPage::~SvxNumOptionsTabPage()
1440 {
1441 	delete aBitmapMB.GetPopupMenu()->GetPopupMenu( MN_GALLERY );
1442 	String* pStr = (String*)aGrfNames.First();
1443 	while( pStr )
1444 	{
1445 		delete pStr;
1446 		pStr = (String*)aGrfNames.Next();
1447 	}
1448     delete pActNum;
1449 	delete pPreviewWIN;
1450 	delete pSaveNum;
1451 }
1452 
1453 /*-----------------03.12.97 07:52-------------------
1454 
1455 --------------------------------------------------*/
SetMetric(FieldUnit eMetric)1456 void SvxNumOptionsTabPage::SetMetric(FieldUnit eMetric)
1457 {
1458 	if(eMetric == FUNIT_MM)
1459 	{
1460 		aWidthMF     .SetDecimalDigits(1);
1461 		aHeightMF     .SetDecimalDigits(1);
1462 	}
1463 	aWidthMF .SetUnit( eMetric );
1464 	aHeightMF .SetUnit( eMetric );
1465 }
1466 
1467 /*-----------------01.12.97 16:30-------------------
1468 
1469 --------------------------------------------------*/
Create(Window * pParent,const SfxItemSet & rAttrSet)1470 SfxTabPage*	SvxNumOptionsTabPage::Create( Window* pParent,
1471 								const SfxItemSet& rAttrSet)
1472 {
1473 	return new SvxNumOptionsTabPage(pParent, rAttrSet);
1474 };
1475 /*-----------------01.12.97 16:29-------------------
1476 
1477 --------------------------------------------------*/
ActivatePage(const SfxItemSet & rSet)1478 void 	SvxNumOptionsTabPage::ActivatePage(const SfxItemSet& rSet)
1479 {
1480 	const SfxPoolItem* pItem;
1481 	const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
1482 	sal_uInt16 nTmpNumLvl = USHRT_MAX;
1483 	if(pExampleSet)
1484 	{
1485 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
1486 			bPreset = ((const SfxBoolItem*)pItem)->GetValue();
1487 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
1488 			nTmpNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
1489 	}
1490 	if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
1491 	{
1492 		delete pSaveNum;
1493 		pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
1494 	}
1495 	//
1496 	bModified = (!pActNum->Get( 0 ) || bPreset);
1497 	if(*pActNum != *pSaveNum ||
1498 		nActNumLvl != nTmpNumLvl)
1499 	{
1500 		nActNumLvl = nTmpNumLvl;
1501 		sal_uInt16 nMask = 1;
1502 		aLevelLB.SetUpdateMode(sal_False);
1503 		aLevelLB.SetNoSelection();
1504 		aLevelLB.SelectEntryPos( pActNum->GetLevelCount(), nActNumLvl == USHRT_MAX);
1505 		if(nActNumLvl != USHRT_MAX)
1506 			for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1507 			{
1508 				if(nActNumLvl & nMask)
1509 					aLevelLB.SelectEntryPos( i, sal_True);
1510 				nMask <<= 1 ;
1511 			}
1512 		aLevelLB.SetUpdateMode(sal_True);
1513 		*pActNum = *pSaveNum;
1514 		InitControls();
1515 	}
1516 
1517 }
1518 /*-----------------01.12.97 16:29-------------------
1519 
1520 --------------------------------------------------*/
DeactivatePage(SfxItemSet * _pSet)1521 int 	SvxNumOptionsTabPage::DeactivatePage(SfxItemSet * _pSet)
1522 {
1523 	if(_pSet)
1524 		FillItemSet(*_pSet);
1525 	return sal_True;
1526 }
1527 /*-----------------01.12.97 16:29-------------------
1528 
1529 --------------------------------------------------*/
FillItemSet(SfxItemSet & rSet)1530 sal_Bool 	SvxNumOptionsTabPage::FillItemSet( SfxItemSet& rSet )
1531 {
1532 	rSet.Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
1533 	if(bModified && pActNum)
1534 	{
1535 		*pSaveNum = *pActNum;
1536 		rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
1537 		rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, sal_False));
1538 	}
1539 	return bModified;
1540 };
1541 /*-----------------01.12.97 16:29-------------------
1542 
1543 --------------------------------------------------*/
Reset(const SfxItemSet & rSet)1544 void 	SvxNumOptionsTabPage::Reset( const SfxItemSet& rSet )
1545 {
1546 	const SfxPoolItem* pItem;
1547 	//im Draw gibt es das Item als WhichId, im Writer nur als SlotId
1548 	SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
1549 	if(eState != SFX_ITEM_SET)
1550 	{
1551 		nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
1552 		eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
1553 
1554 		if( eState != SFX_ITEM_SET )
1555 		{
1556 	        pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
1557 	        eState = SFX_ITEM_SET;
1558 		}
1559 
1560 	}
1561 	DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
1562 	delete pSaveNum;
1563 	pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
1564 
1565 	// Ebenen einfuegen
1566 	if(!aLevelLB.GetEntryCount())
1567 	{
1568 		for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
1569 			aLevelLB.InsertEntry( UniString::CreateFromInt32(i));
1570 		if(pSaveNum->GetLevelCount() > 1)
1571 		{
1572 			String sEntry( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "1 - " ) ) );
1573 			sEntry += UniString::CreateFromInt32( pSaveNum->GetLevelCount() );
1574 			aLevelLB.InsertEntry(sEntry);
1575 			aLevelLB.SelectEntry(sEntry);
1576 		}
1577 		else
1578 			aLevelLB.SelectEntryPos(0);
1579 	}
1580 	else
1581 		aLevelLB.SelectEntryPos(aLevelLB.GetEntryCount() - 1);
1582 
1583 //	nActNumLvl = ((SwNumBulletTabDialog*)GetTabDialog())->GetActNumLevel();
1584 	sal_uInt16 nMask = 1;
1585 	aLevelLB.SetUpdateMode(sal_False);
1586 	aLevelLB.SetNoSelection();
1587 	if(nActNumLvl == USHRT_MAX)
1588 	{
1589 		aLevelLB.SelectEntryPos( pSaveNum->GetLevelCount(), sal_True);
1590 	}
1591 	else
1592 		for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
1593 		{
1594 			if(nActNumLvl & nMask)
1595 				aLevelLB.SelectEntryPos( i, sal_True);
1596 			nMask <<= 1 ;
1597 		}
1598 	aLevelLB.SetUpdateMode(sal_True);
1599 
1600 	if(!pActNum)
1601 		pActNum = new  SvxNumRule(*pSaveNum);
1602 	else if(*pSaveNum != *pActNum)
1603 		*pActNum = *pSaveNum;
1604 	pPreviewWIN->SetNumRule(pActNum);
1605 	aSameLevelCB.Check(pActNum->IsContinuousNumbering());
1606 
1607 	//ColorListBox bei Bedarf fuellen
1608 	if ( pActNum->IsFeatureSupported( NUM_BULLET_COLOR ) )
1609 	{
1610 		SfxObjectShell* pDocSh = SfxObjectShell::Current();
1611 		DBG_ASSERT( pDocSh, "DocShell not found!" );
1612 		XColorListSharedPtr aColorTable;
1613 
1614         if ( pDocSh )
1615         {
1616             pItem = pDocSh->GetItem( SID_COLOR_TABLE );
1617             if ( pItem )
1618                 aColorTable = static_cast< const SvxColorTableItem* >(pItem)->GetColorTable();
1619         }
1620 
1621 		if ( !aColorTable.get() )
1622 		{
1623 			aColorTable = XPropertyListFactory::CreateSharedXColorList(SvtPathOptions().GetPalettePath());
1624 		}
1625 
1626    		aBulColLB.InsertEntry( Color( COL_AUTO ), SVX_RESSTR( RID_SVXSTR_AUTOMATIC ));
1627 
1628 		for ( long i = 0; i < aColorTable->Count(); i++ )
1629 		{
1630 			XColorEntry* pEntry = aColorTable->GetColor(i);
1631 			aBulColLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1632 		}
1633 	}
1634 
1635 	SfxObjectShell* pShell;
1636 	if ( SFX_ITEM_SET == rSet.GetItemState( SID_HTML_MODE, sal_False, &pItem )
1637 		 || ( 0 != ( pShell = SfxObjectShell::Current()) &&
1638 			  0 != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
1639 	{
1640 		sal_uInt16 nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
1641 		bHTMLMode = 0 != (nHtmlMode&HTMLMODE_ON);
1642 	}
1643 
1644 	sal_Bool bCharFmt = pActNum->IsFeatureSupported(NUM_CHAR_STYLE);
1645 	aCharFmtFT.Show(bCharFmt);
1646 	aCharFmtLB.Show(bCharFmt);
1647 
1648 	sal_Bool bContinuous = pActNum->IsFeatureSupported(NUM_CONTINUOUS);
1649 
1650 	sal_Bool bAllLevel = bContinuous && !bHTMLMode;
1651 	aAllLevelFT.Show(bAllLevel);
1652 	aAllLevelNF.Show(bAllLevel);
1653 
1654     aSameLevelFL.Show(bContinuous);
1655 	aSameLevelCB.Show(bContinuous);
1656 	//wieder Missbrauch: im Draw gibt es die Numerierung nur bis zum Bitmap
1657 	// without SVX_NUM_NUMBER_NONE
1658 	//remove types that are unsupported by Draw/Impress
1659 	if(!bContinuous)
1660 	{
1661 		sal_uInt16 nFmtCount = aFmtLB.GetEntryCount();
1662 		for(sal_uInt16 i = nFmtCount; i; i--)
1663 		{
1664 			sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)aFmtLB.GetEntryData(i - 1);
1665 			if(/*SVX_NUM_NUMBER_NONE == nEntryData ||*/
1666                 ((SVX_NUM_BITMAP|LINK_TOKEN) ==  nEntryData))
1667 				aFmtLB.RemoveEntry(i - 1);
1668 		}
1669 	}
1670 	//one must be enabled
1671 	if(!pActNum->IsFeatureSupported(NUM_ENABLE_LINKED_BMP))
1672 	{
1673 		long nData = SVX_NUM_BITMAP|LINK_TOKEN;
1674 		sal_uInt16 nPos = aFmtLB.GetEntryPos((void*)nData);
1675 		if(LISTBOX_ENTRY_NOTFOUND != nPos)
1676 			aFmtLB.RemoveEntry(nPos);
1677 	}
1678 	else if(!pActNum->IsFeatureSupported(NUM_ENABLE_EMBEDDED_BMP))
1679 	{
1680 		long nData = SVX_NUM_BITMAP;
1681 		sal_uInt16 nPos = aFmtLB.GetEntryPos((void*)nData);
1682 		if(LISTBOX_ENTRY_NOTFOUND != nPos)
1683 			aFmtLB.RemoveEntry(nPos);
1684 	}
1685 	if(pActNum->IsFeatureSupported(NUM_SYMBOL_ALIGNMENT))
1686 	{
1687 		aAlignFT.Show();
1688 		aAlignLB.Show();
1689         Size aSz(aFormatFL.GetSizePixel());
1690         aSz.Height() = aLevelFT.GetSizePixel().Height();
1691         aFormatFL.SetSizePixel(aSz);
1692 		aAlignLB.SetSelectHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1693 	}
1694 
1695 	//MegaHack: Aufgrund eines nicht fixbaren 'designfehlers' im Impress
1696 	//Alle arten der numerischen Aufzaehlungen loeschen
1697 	if(pActNum->IsFeatureSupported(NUM_NO_NUMBERS))
1698 	{
1699 		sal_uInt16 nFmtCount = aFmtLB.GetEntryCount();
1700 		for(sal_uInt16 i = nFmtCount; i; i--)
1701 		{
1702 			sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)aFmtLB.GetEntryData(i - 1);
1703 			if( /*nEntryData >= SVX_NUM_CHARS_UPPER_LETTER &&*/  nEntryData <= SVX_NUM_NUMBER_NONE)
1704 				aFmtLB.RemoveEntry(i - 1);
1705 		}
1706 	}
1707 
1708 	InitControls();
1709 	bModified = sal_False;
1710 
1711 }
1712 /*-----------------02.12.97 13:47-------------------
1713 
1714 --------------------------------------------------*/
InitControls()1715 void SvxNumOptionsTabPage::InitControls()
1716 {
1717 	sal_Bool bShowBullet 	= sal_True;
1718 	sal_Bool bShowBitmap 	= sal_True;
1719 	sal_Bool bSameType 		= sal_True;
1720 	sal_Bool bSameStart 	= sal_True;
1721 	sal_Bool bSamePrefix 	= sal_True;
1722 	sal_Bool bSameSuffix 	= sal_True;
1723 	sal_Bool bAllLevel 		= sal_True;
1724 	sal_Bool bSameCharFmt	= sal_True;
1725 	sal_Bool bSameVOrient	= sal_True;
1726 	sal_Bool bSameSize		= sal_True;
1727 	sal_Bool bSameBulColor 	= sal_True;
1728 	sal_Bool bSameBulRelSize= sal_True;
1729 	sal_Bool bSameAdjust 	= sal_True;
1730 
1731 	const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
1732 	String sFirstCharFmt;
1733     sal_Int16 eFirstOrient = text::VertOrientation::NONE;
1734 	Size aFirstSize(0,0);
1735 	sal_uInt16 nMask = 1;
1736 	sal_uInt16 nLvl = USHRT_MAX;
1737 	sal_uInt16 nHighestLevel = 0;
1738 	String aEmptyStr;
1739 
1740 	sal_Bool bBullColor = pActNum->IsFeatureSupported(NUM_BULLET_COLOR);
1741 	sal_Bool bBullRelSize = pActNum->IsFeatureSupported(NUM_BULLET_REL_SIZE);
1742 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1743 	{
1744 		if(nActNumLvl & nMask)
1745 		{
1746 			aNumFmtArr[i] = &pActNum->GetLevel(i);
1747 			bShowBullet &= aNumFmtArr[i]->GetNumberingType() == SVX_NUM_CHAR_SPECIAL;
1748 			bShowBitmap &= (aNumFmtArr[i]->GetNumberingType()&(~LINK_TOKEN)) == SVX_NUM_BITMAP;
1749 			if(USHRT_MAX == nLvl)
1750 			{
1751 				nLvl = i;
1752 				sFirstCharFmt = aNumFmtArr[i]->GetCharFmtName();
1753 				eFirstOrient = aNumFmtArr[i]->GetVertOrient();
1754 				if(bShowBitmap)
1755 					aFirstSize = aNumFmtArr[i]->GetGraphicSize();
1756 			}
1757 			if( i > nLvl)
1758 			{
1759 				bSameType &=   aNumFmtArr[i]->GetNumberingType() == aNumFmtArr[nLvl]->GetNumberingType();
1760 				bSameStart = aNumFmtArr[i]->GetStart() == aNumFmtArr[nLvl]->GetStart();
1761 
1762 				bSamePrefix = aNumFmtArr[i]->GetPrefix() == aNumFmtArr[nLvl]->GetPrefix();
1763 				bSameSuffix = aNumFmtArr[i]->GetSuffix() == aNumFmtArr[nLvl]->GetSuffix();
1764 				bAllLevel &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[nLvl]->GetIncludeUpperLevels();
1765 				bSameCharFmt 	&= 	sFirstCharFmt == aNumFmtArr[i]->GetCharFmtName();
1766 				bSameVOrient    &= eFirstOrient == aNumFmtArr[i]->GetVertOrient();
1767 				if(bShowBitmap && bSameSize)
1768 					bSameSize &= aNumFmtArr[i]->GetGraphicSize() == aFirstSize;
1769 				bSameBulColor &= aNumFmtArr[i]->GetBulletColor() == aNumFmtArr[nLvl]->GetBulletColor();
1770 				bSameBulRelSize &= aNumFmtArr[i]->GetBulletRelSize() == aNumFmtArr[nLvl]->GetBulletRelSize();
1771 				bSameAdjust 	&= aNumFmtArr[i]->GetNumAdjust() == aNumFmtArr[nLvl]->GetNumAdjust();
1772 			}
1773 			nHighestLevel = i;
1774 		}
1775 		else
1776 			aNumFmtArr[i] = 0;
1777 
1778 		nMask <<= 1 ;
1779 
1780 	}
1781 	SwitchNumberType(bShowBullet ? 1 : bShowBitmap ? 2 : 0);
1782     CheckForStartValue_Impl(aNumFmtArr[nLvl]->GetNumberingType());
1783 	if(bShowBitmap)
1784 	{
1785         if(!bSameVOrient || eFirstOrient == text::VertOrientation::NONE)
1786 			aOrientLB.SetNoSelection();
1787 		else
1788 			aOrientLB.SelectEntryPos(
1789                 sal::static_int_cast< sal_uInt16 >(eFirstOrient - 1));
1790                 // kein text::VertOrientation::NONE
1791 
1792 		if(bSameSize)
1793 		{
1794 			SetMetricValue(aHeightMF, aFirstSize.Height(), eCoreUnit);
1795 			SetMetricValue(aWidthMF, aFirstSize.Width(), eCoreUnit);
1796 		}
1797 		else
1798 		{
1799 			aHeightMF.SetText(aEmptyStr);
1800 			aWidthMF.SetText(aEmptyStr);
1801 		}
1802 	}
1803 
1804 	if(bSameType)
1805 	{
1806 		sal_uInt16 nLBData = (sal_uInt16) aNumFmtArr[nLvl]->GetNumberingType();
1807 		aFmtLB.SelectEntryPos(aFmtLB.GetEntryPos( (void*)sal::static_int_cast<sal_uIntPtr>( nLBData ) ));
1808 	}
1809 	else
1810 		aFmtLB.SetNoSelection();
1811 
1812 	aAllLevelNF.Enable(nHighestLevel > 0 && !aSameLevelCB.IsChecked());
1813     aAllLevelNF.SetMax(nHighestLevel + 1);
1814 	if(bAllLevel)
1815 	{
1816 		aAllLevelNF.SetValue(aNumFmtArr[nLvl]->GetIncludeUpperLevels());
1817 	}
1818 	else
1819 	{
1820 		aAllLevelNF.SetText(aEmptyStr);
1821 	}
1822 	if(bSameAdjust)
1823 	{
1824 		sal_uInt16 nPos = 1; // zentriert
1825 		if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_LEFT)
1826 			nPos = 0;
1827 		else if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_RIGHT)
1828 			nPos = 2;
1829 		aAlignLB.SelectEntryPos(nPos);
1830 	}
1831 	else
1832 	{
1833 		aAlignLB.SetNoSelection();
1834 	}
1835 
1836 	if(bBullRelSize)
1837 	{
1838 		if(bSameBulRelSize)
1839 			aBulRelSizeMF.SetValue(aNumFmtArr[nLvl]->GetBulletRelSize());
1840 		else
1841 			aBulRelSizeMF.SetText(aEmptyStr);
1842 	}
1843 	if(bBullColor)
1844 	{
1845 		if(bSameBulColor)
1846 			aBulColLB.SelectEntry(aNumFmtArr[nLvl]->GetBulletColor());
1847 		else
1848 			aBulColLB.SetNoSelection();
1849 	}
1850 	switch(nBullet)
1851 	{
1852 		case SHOW_NUMBERING:
1853 			if(bSameStart)
1854 			{
1855 				aStartED.SetValue(aNumFmtArr[nLvl]->GetStart());
1856 			}
1857 			else
1858 				aStartED.SetText(aEmptyStr);
1859 		break;
1860 		case SHOW_BULLET:
1861 		{
1862 //				const Font* pFnt = aNumFmtArr[Lvl]->GetBulletFont();
1863 //				if(pFnt)
1864 //					ChgTxtFont(aBulletFT, *pFnt);
1865 //				aBulletFT.SetText(String((char)aNumFmtArr[nLvl]->GetBulletChar()));
1866 		}
1867 		break;
1868 		case SHOW_BITMAP:
1869 		break;
1870 	}
1871 
1872 	if(bSamePrefix)
1873 		aPrefixED.SetText(aNumFmtArr[nLvl]->GetPrefix());
1874 	else
1875 		aPrefixED.SetText(aEmptyStr);
1876 	if(bSameSuffix)
1877 		aSuffixED.SetText(aNumFmtArr[nLvl]->GetSuffix());
1878 	else
1879 		aSuffixED.SetText(aEmptyStr);
1880 
1881 	if(bSameCharFmt)
1882 	{
1883 		if(sFirstCharFmt.Len())
1884 				aCharFmtLB.SelectEntry(sFirstCharFmt);
1885 		else
1886 			aCharFmtLB.SelectEntryPos( 0 );
1887 	}
1888 	else
1889 		aCharFmtLB.SetNoSelection();
1890 
1891     pPreviewWIN->SetLevel(nActNumLvl);
1892 	pPreviewWIN->Invalidate();
1893 }
1894 
1895 /*-----------------02.12.97 14:01-------------------
1896 	 0 - Nummer; 1 - Bullet; 2 - Bitmap
1897 --------------------------------------------------*/
1898 
SwitchNumberType(sal_uInt8 nType,sal_Bool)1899 void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType, sal_Bool )
1900 {
1901 	if(nBullet == nType)
1902 		return;
1903 	nBullet = nType;
1904 	sal_Bool bBitmap = sal_False;
1905 	sal_Bool bBullet = sal_False;
1906 	sal_Bool bEnableBitmap = sal_False;
1907 	if(nType == SHOW_NUMBERING)
1908 	{
1909 		// Label umschalten, alten Text merken
1910 		aStartFT.SetText(sStartWith);
1911 
1912 	}
1913 	else if(nType == SHOW_BULLET)
1914 	{
1915 		// Label umschalten, alten Text merken
1916 		aStartFT.SetText(sBullet);
1917 		bBullet = sal_True;
1918 	}
1919 	else
1920 	{
1921 		bBitmap = sal_True;
1922 		bEnableBitmap = sal_True;
1923 	}
1924 	sal_Bool bNumeric = !(bBitmap||bBullet);
1925 	aPrefixFT.Show(bNumeric);
1926 	aPrefixED.Show(bNumeric);
1927 	aSuffixFT.Show(bNumeric);
1928 	aSuffixED.Show(bNumeric);
1929 
1930 	sal_Bool bCharFmt = pActNum->IsFeatureSupported(NUM_CHAR_STYLE);
1931 	aCharFmtFT.Show(!bBitmap && bCharFmt);
1932 	aCharFmtLB.Show(!bBitmap && bCharFmt);
1933 
1934 	// das ist eigentlich Missbrauch, da fuer die vollst. Numerierung kein
1935 	// eigenes Flag existiert
1936 	sal_Bool bAllLevelFeature = pActNum->IsFeatureSupported(NUM_CONTINUOUS);
1937 	sal_Bool bAllLevel = bNumeric && bAllLevelFeature && !bHTMLMode;
1938 	aAllLevelFT.Show(bAllLevel);
1939 	aAllLevelNF.Show(bAllLevel);
1940 
1941 	aStartFT.Show(!bBitmap);
1942 	aStartED.Show(!(bBullet||bBitmap));
1943 
1944 	aBulletPB.Show(bBullet);
1945 	sal_Bool bBullColor = pActNum->IsFeatureSupported(NUM_BULLET_COLOR);
1946 	aBulColorFT.Show( 	!bBitmap && bBullColor );
1947 	aBulColLB.Show(		!bBitmap && bBullColor );
1948 	sal_Bool bBullResSize = pActNum->IsFeatureSupported(NUM_BULLET_REL_SIZE);
1949 	aBulRelSizeFT.Show(	!bBitmap && bBullResSize );
1950 	aBulRelSizeMF.Show(	!bBitmap && bBullResSize );
1951 
1952 	aBitmapFT	.Show(bBitmap);
1953 	aBitmapMB	.Show(bBitmap);
1954 
1955 	aSizeFT		.Show(bBitmap);
1956 	aWidthMF	.Show(bBitmap);
1957 	aMultFT	    .Show(bBitmap);
1958 	aHeightMF	.Show(bBitmap);
1959 	aRatioCB	.Show(bBitmap);
1960 
1961 	aOrientFT	.Show(bBitmap &&  bAllLevelFeature);
1962 	aOrientLB	.Show(bBitmap &&  bAllLevelFeature);
1963 
1964 	aSizeFT		.Enable(bEnableBitmap);
1965 	aWidthMF	.Enable(bEnableBitmap);
1966 	aMultFT	    .Enable(bEnableBitmap);
1967 	aHeightMF	.Enable(bEnableBitmap);
1968 	aRatioCB	.Enable(bEnableBitmap);
1969 	aOrientFT	.Enable(bEnableBitmap);
1970 	aOrientLB	.Enable(bEnableBitmap);
1971 
1972 }
1973 /*-----------------02.12.97 13:51-------------------
1974 
1975 --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,LevelHdl_Impl,ListBox *,pBox)1976 IMPL_LINK( SvxNumOptionsTabPage, LevelHdl_Impl, ListBox *, pBox )
1977 {
1978 	sal_uInt16 nSaveNumLvl = nActNumLvl;
1979 	nActNumLvl = 0;
1980 	if(pBox->IsEntryPosSelected( pActNum->GetLevelCount() ) &&
1981 		(pBox->GetSelectEntryCount() == 1 || nSaveNumLvl != 0xffff))
1982 	{
1983 		nActNumLvl = 0xFFFF;
1984 		pBox->SetUpdateMode(sal_False);
1985 		for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1986 			pBox->SelectEntryPos( i, sal_False );
1987 		pBox->SetUpdateMode(sal_True);
1988 	}
1989 	else if(pBox->GetSelectEntryCount())
1990 	{
1991 		sal_uInt16 nMask = 1;
1992 		for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1993 		{
1994 			if(pBox->IsEntryPosSelected( i ))
1995 				nActNumLvl |= nMask;
1996 			nMask <<= 1;
1997 		}
1998 		pBox->SelectEntryPos( pActNum->GetLevelCount(), sal_False );
1999 	}
2000 	else
2001 	{
2002 		nActNumLvl = nSaveNumLvl;
2003 		sal_uInt16 nMask = 1;
2004 		for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
2005 		{
2006 			if(nActNumLvl & nMask)
2007 			{
2008 				pBox->SelectEntryPos(i);
2009 				break;
2010 			}
2011 			nMask <<=1;
2012 		}
2013 	}
2014 	InitControls();
2015 	return 0;
2016 }
2017 /* -----------------------------05.04.2002 15:30------------------------------
2018 
2019  ---------------------------------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,PreviewInvalidateHdl_Impl,Timer *,EMPTYARG)2020 IMPL_LINK( SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl, Timer*, EMPTYARG )
2021 {
2022     pPreviewWIN->Invalidate();
2023     return 0;
2024 }
2025 /*-----------------03.12.97 12:01-------------------
2026 
2027 --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,AllLevelHdl_Impl,NumericField *,pBox)2028 IMPL_LINK( SvxNumOptionsTabPage, AllLevelHdl_Impl, NumericField*, pBox )
2029 {
2030 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2031 	{
2032 		sal_uInt16 nMask = 1;
2033 		for(sal_uInt16 e = 0; e < pActNum->GetLevelCount(); e++)
2034 		{
2035 			if(nActNumLvl & nMask)
2036 			{
2037 				SvxNumberFormat aNumFmt(pActNum->GetLevel(e));
2038 				aNumFmt.SetIncludeUpperLevels((sal_uInt8) std::min(pBox->GetValue(), sal_Int64(e + 1)) );
2039 				pActNum->SetLevel(e, aNumFmt);
2040 			}
2041 			nMask <<= 1;
2042 		}
2043 	}
2044 	SetModified();
2045 	return 0;
2046 }
2047 
2048 /*-----------------02.12.97 08:56-------------------
2049 
2050 --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,NumberTypeSelectHdl_Impl,ListBox *,pBox)2051 IMPL_LINK( SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, ListBox *, pBox )
2052 {
2053 	String sSelectStyle;
2054 	sal_Int16 eOldType;
2055 	sal_Bool bShowOrient = sal_False;
2056 	sal_Bool bBmp = sal_False;
2057 	String aEmptyStr;
2058 	sal_uInt16 nMask = 1;
2059 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2060 	{
2061 		if(nActNumLvl & nMask)
2062 		{
2063 			SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2064 			eOldType = aNumFmt.GetNumberingType();
2065 			// PAGEDESC gibt es nicht
2066 			sal_uInt16 nNumType = (sal_uInt16)(sal_uLong)pBox->GetEntryData(pBox->GetSelectEntryPos());
2067 			aNumFmt.SetNumberingType((sal_Int16)nNumType);
2068             sal_uInt16 nNumberingType = aNumFmt.GetNumberingType();
2069             if(SVX_NUM_BITMAP == (nNumberingType&(~LINK_TOKEN)))
2070 			{
2071 				bBmp |= 0 != aNumFmt.GetBrush();
2072 				aNumFmt.SetIncludeUpperLevels( sal_False );
2073 				aNumFmt.SetSuffix( aEmptyStr );
2074 				aNumFmt.SetPrefix( aEmptyStr );
2075 				if(!bBmp)
2076 					aNumFmt.SetGraphic(aEmptyStr);
2077 				pActNum->SetLevel(i, aNumFmt);
2078 				SwitchNumberType(SHOW_BITMAP, bBmp );
2079 				bShowOrient = sal_True;
2080 			}
2081             else if( SVX_NUM_CHAR_SPECIAL == nNumberingType )
2082 			{
2083 				aNumFmt.SetIncludeUpperLevels( sal_False );
2084 				aNumFmt.SetSuffix( aEmptyStr );
2085 				aNumFmt.SetPrefix( aEmptyStr );
2086 				if( !aNumFmt.GetBulletFont() )
2087 					aNumFmt.SetBulletFont(&aActBulletFont);
2088 				if( !aNumFmt.GetBulletChar() )
2089 					aNumFmt.SetBulletChar( SVX_DEF_BULLET );
2090 				pActNum->SetLevel(i, aNumFmt);
2091 				SwitchNumberType(SHOW_BULLET);
2092 				//ChgTxtFont(aBulletFT, *aNumFmt.GetBulletFont());
2093 				//aBulletFT.SetText( aNumFmt.GetBulletChar() );
2094 				// Zuweisung der Zeichenvorlage automatisch
2095 				if(bAutomaticCharStyles)
2096 				{
2097 					sSelectStyle = sBulletCharFmtName;
2098 				}
2099 			}
2100 			else
2101 			{
2102 				aNumFmt.SetPrefix( aPrefixED.GetText() );
2103 				aNumFmt.SetSuffix( aSuffixED.GetText() );
2104 //				aNumFmt.SetBulletFont(0);
2105 				SwitchNumberType(SHOW_NUMBERING);
2106 				pActNum->SetLevel(i, aNumFmt);
2107                 CheckForStartValue_Impl(nNumberingType);
2108 
2109 				// Zuweisung der Zeichenvorlage automatisch
2110 				if(bAutomaticCharStyles)
2111 				{
2112 					sSelectStyle = sNumCharFmtName;
2113 				}
2114 			}
2115 		}
2116 		nMask <<= 1;
2117 	}
2118 	sal_Bool bAllLevelFeature = pActNum->IsFeatureSupported(NUM_CONTINUOUS);
2119 	if(bShowOrient && bAllLevelFeature)
2120 	{
2121 		aOrientFT.Show();
2122 		aOrientLB.Show();
2123 	}
2124 	else
2125 	{
2126 		aOrientFT.Hide();
2127 		aOrientLB.Hide();
2128 	}
2129 	SetModified();
2130 	if(sSelectStyle.Len())
2131 	{
2132 		aCharFmtLB.SelectEntry(sSelectStyle);
2133 		CharFmtHdl_Impl(&aCharFmtLB);
2134 		// bAutomaticCharStyles wird im CharFmtHdl_Impl zurueckgesetzt
2135 		bAutomaticCharStyles = sal_True;
2136 	}
2137 	return 0;
2138 }
2139 /* -----------------06.11.2002 14:27-----------------
2140  *
2141  * --------------------------------------------------*/
CheckForStartValue_Impl(sal_uInt16 nNumberingType)2142 void SvxNumOptionsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType)
2143 {
2144     sal_Bool bIsNull = aStartED.GetValue() == 0;
2145     sal_Bool bNoZeroAllowed = nNumberingType < SVX_NUM_ARABIC ||
2146                         SVX_NUM_CHARS_UPPER_LETTER_N == nNumberingType ||
2147                         SVX_NUM_CHARS_LOWER_LETTER_N == nNumberingType;
2148     aStartED.SetMin(bNoZeroAllowed ? 1 : 0);
2149     if(bIsNull && bNoZeroAllowed)
2150         aStartED.GetModifyHdl().Call(&aStartED);
2151 }
2152 /*-----------------03.12.97 16:43-------------------
2153 
2154 --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,OrientHdl_Impl,ListBox *,pBox)2155 IMPL_LINK( SvxNumOptionsTabPage, OrientHdl_Impl, ListBox *, pBox )
2156 {
2157 	sal_uInt16 nPos = pBox->GetSelectEntryPos();
2158 	nPos ++; // kein VERT_NONE
2159 
2160 	sal_uInt16 nMask = 1;
2161 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2162 	{
2163 		if(nActNumLvl & nMask)
2164 		{
2165 			SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2166 			if(SVX_NUM_BITMAP == (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
2167 			{
2168 				const SvxBrushItem* pBrushItem =  aNumFmt.GetBrush();
2169 				const Size& rSize = aNumFmt.GetGraphicSize();
2170                 sal_Int16 eOrient = (sal_Int16)nPos;
2171 				aNumFmt.SetGraphicBrush( pBrushItem, &rSize, &eOrient );
2172 				pActNum->SetLevel(i, aNumFmt);
2173 			}
2174 		}
2175 		nMask <<= 1;
2176 	}
2177 	SetModified(sal_False);
2178 	return 0;
2179 
2180 }
2181 
2182 /*-----------------06.12.97 12:00-------------------
2183 
2184 --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,SameLevelHdl_Impl,CheckBox *,pBox)2185 IMPL_LINK( SvxNumOptionsTabPage, SameLevelHdl_Impl, CheckBox *, pBox )
2186 {
2187 	sal_Bool bSet = pBox->IsChecked();
2188 	pActNum->SetContinuousNumbering(bSet);
2189 	sal_Bool bRepaint = sal_False;
2190 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2191 	{
2192 		SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2193 		if(aNumFmt.GetNumberingType() != SVX_NUM_NUMBER_NONE)
2194 		{
2195 			bRepaint = sal_True;
2196 			break;
2197 		}
2198 	}
2199 	SetModified(bRepaint);
2200 	InitControls();
2201 	return 0;
2202 }
2203 /* -----------------16.11.98 14:20-------------------
2204  *
2205  * --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,BulColorHdl_Impl,ColorListBox *,pBox)2206 IMPL_LINK( SvxNumOptionsTabPage, BulColorHdl_Impl, ColorListBox*, pBox )
2207 {
2208 	Color nSetColor = pBox->GetSelectEntryColor();
2209 
2210 	sal_uInt16 nMask = 1;
2211 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2212 	{
2213 		if(nActNumLvl & nMask)
2214 		{
2215 			SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2216 			aNumFmt.SetBulletColor(nSetColor);
2217 			pActNum->SetLevel(i, aNumFmt);
2218 		}
2219 		nMask <<= 1;
2220 	}
2221 	SetModified();
2222 	return 0;
2223 }
2224 /* -----------------16.11.98 14:20-------------------
2225  *
2226  * --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,BulRelSizeHdl_Impl,MetricField *,pField)2227 IMPL_LINK( SvxNumOptionsTabPage, BulRelSizeHdl_Impl, MetricField *, pField)
2228 {
2229 	sal_uInt16 nRelSize = (sal_uInt16)pField->GetValue();
2230 
2231 	sal_uInt16 nMask = 1;
2232 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2233 	{
2234 		if(nActNumLvl & nMask)
2235 		{
2236 			SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2237 			aNumFmt.SetBulletRelSize(nRelSize);
2238 			pActNum->SetLevel(i, aNumFmt);
2239 		}
2240 		nMask <<= 1;
2241 	}
2242 	SetModified();
2243 	return 0;
2244 }
2245 
2246 /*-----------------02.12.97 10:50-------------------
2247 
2248 --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,GraphicHdl_Impl,MenuButton *,pButton)2249 IMPL_LINK( SvxNumOptionsTabPage, GraphicHdl_Impl, MenuButton *, pButton )
2250 {
2251 	sal_uInt16 					nItemId = pButton->GetCurItemId();
2252 	String 					aGrfName;
2253 	Size 					aSize;
2254 	sal_Bool				bSucc(sal_False);
2255 	SvxOpenGraphicDialog	aGrfDlg( CUI_RES(RID_STR_EDIT_GRAPHIC) );
2256 
2257 	if(MN_GALLERY_ENTRY <= nItemId )
2258 	{
2259 		aGrfName = *((String*)aGrfNames.GetObject( nItemId - MN_GALLERY_ENTRY));
2260         Graphic aGraphic;
2261         if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nItemId - MN_GALLERY_ENTRY, &aGraphic))
2262         {
2263             aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
2264             bSucc = sal_True;
2265 		}
2266 	}
2267 	else
2268 	{
2269 		aGrfDlg.EnableLink( sal_False );
2270 		aGrfDlg.AsLink( sal_False );
2271 		if ( !aGrfDlg.Execute() )
2272 		{
2273 			// ausgewaehlten Filter merken
2274 			aGrfName = aGrfDlg.GetPath();
2275 
2276 			Graphic	aGraphic;
2277 			if( !aGrfDlg.GetGraphic(aGraphic) )
2278 			{
2279 				aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
2280 				bSucc = sal_True;
2281 			}
2282 		}
2283 	}
2284 	if(bSucc)
2285 	{
2286 		aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)eCoreUnit);
2287 
2288 		sal_uInt16 nMask = 1;
2289 		for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2290 		{
2291 			if(nActNumLvl & nMask)
2292 			{
2293 				SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2294 				aNumFmt.SetCharFmtName(sNumCharFmtName);
2295 				aNumFmt.SetGraphic(aGrfName);
2296 
2297 				// Size schon mal fuer spaeteren Groessenabgleich setzen
2298 				const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
2299                 // initiate asynchronous loading
2300                 sal_Int16 eOrient = aNumFmt.GetVertOrient();
2301 				aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient );
2302 				aInitSize[i] = aNumFmt.GetGraphicSize();
2303 
2304 				pActNum->SetLevel(i, aNumFmt);
2305 			}
2306 			nMask <<= 1;
2307 		}
2308 		aRatioCB .Enable();
2309 		aSizeFT .Enable();
2310 		aMultFT.Enable();
2311 		aWidthMF .Enable();
2312 		aHeightMF.Enable();
2313 		SetMetricValue(aWidthMF, aSize.Width(), eCoreUnit);
2314 		SetMetricValue(aHeightMF, aSize.Height(), eCoreUnit);
2315 		aOrientFT.Enable();
2316 		aOrientLB.Enable();
2317 		SetModified();
2318         //needed due to asynchronous loading of graphics in the SvxBrushItem
2319         aInvalidateTimer.Start();
2320 	}
2321 	return 0;
2322 }
2323 /* -----------------27.07.99 12:20-------------------
2324 
2325  --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,PopupActivateHdl_Impl,Menu *,EMPTYARG)2326 IMPL_LINK( SvxNumOptionsTabPage, PopupActivateHdl_Impl, Menu *, EMPTYARG )
2327 {
2328 	if(!bMenuButtonInitialized)
2329 	{
2330 		bMenuButtonInitialized = sal_True;
2331 		EnterWait();
2332 		PopupMenu* pPopup = aBitmapMB.GetPopupMenu()->GetPopupMenu( MN_GALLERY );
2333 		GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames);
2334 		if(aGrfNames.Count())
2335 		{
2336 			pPopup->RemoveItem( pPopup->GetItemPos( NUM_NO_GRAPHIC ));
2337 			String aEmptyStr;
2338             GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS);
2339 
2340             for(sal_uInt16 i = 0; i < aGrfNames.Count(); i++)
2341 			{
2342                 Graphic aGraphic;
2343                 String sGrfName = *(const String*)aGrfNames.GetObject(i);
2344                 INetURLObject aObj(sGrfName);
2345                 if(aObj.GetProtocol() == INET_PROT_FILE)
2346                     sGrfName = aObj.PathToFileName();
2347                 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, i, &aGraphic))
2348                 {
2349                     Bitmap aBitmap(aGraphic.GetBitmap());
2350 					Size aSize(aBitmap.GetSizePixel());
2351 					if(aSize.Width() > MAX_BMP_WIDTH ||
2352 						aSize.Height() > MAX_BMP_HEIGHT)
2353 					{
2354 						sal_Bool bWidth = aSize.Width() > aSize.Height();
2355 						double nScale = bWidth ?
2356 											(double)MAX_BMP_WIDTH / (double)aSize.Width():
2357 												(double)MAX_BMP_HEIGHT / (double)aSize.Height();
2358 						aBitmap.Scale(nScale, nScale);
2359 					}
2360 					Image aImage(aBitmap);
2361 
2362                     pPopup->InsertItem(MN_GALLERY_ENTRY + i, sGrfName, aImage );
2363 				}
2364 				else
2365 				{
2366 					Image aImage;
2367 					pPopup->InsertItem(
2368                         MN_GALLERY_ENTRY + i, sGrfName, aImage );
2369 				}
2370 			}
2371             GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS);
2372         }
2373 		LeaveWait();
2374 	}
2375 	return 0;
2376 }
2377 
2378 /*-----------------02.12.97 10:58-------------------
2379 
2380 --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,BulletHdl_Impl,Button *,EMPTYARG)2381 IMPL_LINK( SvxNumOptionsTabPage, BulletHdl_Impl, Button *, EMPTYARG )
2382 {
2383 	SvxCharacterMap* pMap = new SvxCharacterMap( this, sal_True );
2384 
2385 	sal_uInt16 nMask = 1;
2386 	const Font* pFmtFont = 0;
2387 	sal_Bool bSameBullet = sal_True;
2388 	sal_Unicode cBullet = 0;
2389 	sal_Bool bFirst = sal_True;
2390 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2391 	{
2392 		if(nActNumLvl & nMask)
2393 		{
2394 			const SvxNumberFormat& 	rCurFmt = pActNum->GetLevel(i);
2395 			if(bFirst)
2396 			{
2397 				 cBullet = rCurFmt.GetBulletChar();
2398 			}
2399 			else if(rCurFmt.GetBulletChar() != cBullet )
2400 			{
2401 				bSameBullet = sal_False;
2402 				break;
2403 			}
2404 			if(!pFmtFont)
2405 				pFmtFont = rCurFmt.GetBulletFont();
2406 			bFirst = sal_False;
2407 		}
2408 		nMask <<= 1;
2409 
2410 	}
2411 
2412 	if(pFmtFont)
2413 		pMap->SetCharFont(*pFmtFont);
2414 	else
2415 		pMap->SetCharFont(aActBulletFont);
2416 	if(bSameBullet)
2417 		pMap->SetChar( cBullet );
2418 	if(pMap->Execute() == RET_OK)
2419 	{
2420 		// Font Numrules umstellen
2421 		aActBulletFont = pMap->GetCharFont();
2422 
2423 		sal_uInt16 _nMask = 1;
2424 		for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2425 		{
2426 			if(nActNumLvl & _nMask)
2427 			{
2428 				SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2429 				aNumFmt.SetBulletFont(&aActBulletFont); ;
2430 				aNumFmt.SetBulletChar( (sal_Unicode) pMap->GetChar() );
2431 				pActNum->SetLevel(i, aNumFmt);
2432 			}
2433 			_nMask <<= 1;
2434 		}
2435 
2436 		SetModified();
2437 	}
2438 	delete pMap;
2439 	return 0;
2440 }
2441 
2442 /*-----------------03.03.97 15:21-------------------
2443 
2444 --------------------------------------------------*/
2445 
IMPL_LINK(SvxNumOptionsTabPage,SizeHdl_Impl,MetricField *,pField)2446 IMPL_LINK( SvxNumOptionsTabPage, SizeHdl_Impl, MetricField *, pField)
2447 {
2448 	sal_Bool bWidth = pField == &aWidthMF;
2449 	bLastWidthModified = bWidth;
2450 	sal_Bool bRatio = aRatioCB.IsChecked();
2451 	long nWidthVal = static_cast<long>(aWidthMF.Denormalize(aWidthMF.GetValue(FUNIT_100TH_MM)));
2452 	long nHeightVal = static_cast<long>(aHeightMF.Denormalize(aHeightMF.GetValue(FUNIT_100TH_MM)));
2453 	nWidthVal = OutputDevice::LogicToLogic( nWidthVal ,
2454 												MAP_100TH_MM, (MapUnit)eCoreUnit );
2455 	nHeightVal = OutputDevice::LogicToLogic( nHeightVal,
2456 												MAP_100TH_MM, (MapUnit)eCoreUnit);
2457 	double	fSizeRatio;
2458 
2459 	sal_Bool bRepaint = sal_False;
2460 	sal_uInt16 nMask = 1;
2461 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2462 	{
2463 		if(nActNumLvl & nMask)
2464 		{
2465 			SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2466 			if(SVX_NUM_BITMAP == (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
2467 			{
2468 				Size aSize(aNumFmt.GetGraphicSize() );
2469 				Size aSaveSize(aSize);
2470 
2471 				if (aInitSize[i].Height())
2472 					fSizeRatio = (double)aInitSize[i].Width() / (double)aInitSize[i].Height();
2473 				else
2474 					fSizeRatio = (double)1;
2475 
2476 				if(bWidth)
2477 				{
2478 					long nDelta = nWidthVal - aInitSize[i].Width();
2479 					aSize.Width() = nWidthVal;
2480 					if (bRatio)
2481 					{
2482 						aSize.Height() = aInitSize[i].Height() + (long)((double)nDelta / fSizeRatio);
2483 						aHeightMF.SetUserValue(aHeightMF.Normalize(
2484 							OutputDevice::LogicToLogic( aSize.Height(), (MapUnit)eCoreUnit, MAP_100TH_MM )),
2485 								FUNIT_100TH_MM);
2486 					}
2487 				}
2488 				else
2489 				{
2490 					long nDelta = nHeightVal - aInitSize[i].Height();
2491 					aSize.Height() = nHeightVal;
2492 					if (bRatio)
2493 					{
2494 						aSize.Width() = aInitSize[i].Width() + (long)((double)nDelta * fSizeRatio);
2495 						aWidthMF.SetUserValue(aWidthMF.Normalize(
2496 							OutputDevice::LogicToLogic( aSize.Width(), (MapUnit)eCoreUnit, MAP_100TH_MM )),
2497 								FUNIT_100TH_MM);
2498 					}
2499 				}
2500 				const SvxBrushItem* pBrushItem =  aNumFmt.GetBrush();
2501                 sal_Int16 eOrient = aNumFmt.GetVertOrient();
2502 				if(aSize != aSaveSize)
2503 					bRepaint = sal_True;
2504 				aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient );
2505 				pActNum->SetLevel(i, aNumFmt);
2506 			}
2507 		}
2508 		nMask <<= 1;
2509 	}
2510 	SetModified(bRepaint);
2511 	return 0;
2512 }
2513 
2514 /*------------------------------------------------------------------------
2515  Beschreibung:
2516 ------------------------------------------------------------------------*/
2517 
IMPL_LINK(SvxNumOptionsTabPage,RatioHdl_Impl,CheckBox *,pBox)2518 IMPL_LINK( SvxNumOptionsTabPage, RatioHdl_Impl, CheckBox *, pBox )
2519 {
2520 	if (pBox->IsChecked())
2521 	{
2522 		if (bLastWidthModified)
2523 			SizeHdl_Impl(&aWidthMF);
2524 		else
2525 			SizeHdl_Impl(&aHeightMF);
2526 	}
2527 	return 0;
2528 }
2529 
2530 /*-----------------02.12.97 16:07-------------------
2531 
2532 --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,CharFmtHdl_Impl,ListBox *,EMPTYARG)2533 IMPL_LINK( SvxNumOptionsTabPage, CharFmtHdl_Impl, ListBox *, EMPTYARG )
2534 {
2535 	bAutomaticCharStyles = sal_False;
2536 	sal_uInt16 nEntryPos = aCharFmtLB.GetSelectEntryPos();
2537 	String sEntry = aCharFmtLB.GetSelectEntry();
2538 	sal_uInt16 nMask = 1;
2539 	String aEmptyStr;
2540 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2541 	{
2542 		if(nActNumLvl & nMask)
2543 		{
2544 			SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2545 			if( 0 == nEntryPos )
2546 				aNumFmt.SetCharFmtName(aEmptyStr);
2547 			else
2548 			{
2549 				if(SVX_NUM_BITMAP != (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
2550 					aNumFmt.SetCharFmtName(sEntry);
2551 			}
2552 			pActNum->SetLevel(i, aNumFmt);
2553 		}
2554 		nMask <<= 1;
2555 	}
2556 	SetModified(sal_False);
2557 	return 0;
2558 
2559 };
2560 
2561 /*-----------------03.12.97 11:01-------------------
2562 
2563 --------------------------------------------------*/
IMPL_LINK(SvxNumOptionsTabPage,EditModifyHdl_Impl,Edit *,pEdit)2564 IMPL_LINK( SvxNumOptionsTabPage, EditModifyHdl_Impl, Edit *, pEdit )
2565 {
2566 	sal_Bool bPrefix = pEdit == &aPrefixED;
2567 	sal_Bool bSuffix = pEdit == &aSuffixED;
2568 	sal_Bool bStart = pEdit == &aStartED;
2569 	sal_uInt16 nMask = 1;
2570 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2571 	{
2572 		if(nActNumLvl & nMask)
2573 		{
2574 			SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2575 			if(bPrefix)
2576 				aNumFmt.SetPrefix( aPrefixED.GetText() );
2577 			else if(bSuffix)
2578 				aNumFmt.SetSuffix( aSuffixED.GetText() );
2579 			else if(bStart)
2580 				aNumFmt.SetStart( (sal_uInt16)aStartED.GetValue() );
2581 			else //align
2582 			{
2583 				sal_uInt16 nPos = aAlignLB.GetSelectEntryPos();
2584 				SvxAdjust eAdjust = SVX_ADJUST_CENTER;
2585 				if(nPos == 0)
2586 					eAdjust = SVX_ADJUST_LEFT;
2587 				else if(nPos == 2)
2588 					eAdjust = SVX_ADJUST_RIGHT;
2589 				aNumFmt.SetNumAdjust( eAdjust );
2590 			}
2591 			pActNum->SetLevel(i, aNumFmt);
2592 		}
2593 		nMask <<= 1;
2594 	}
2595 	SetModified();
2596 
2597 	return 0;
2598 }
2599 
2600 /*-----------------09.12.97 11:49-------------------
2601 
2602 --------------------------------------------------*/
lcl_DrawGraphic(VirtualDevice * pVDev,const SvxNumberFormat & rFmt,sal_uInt16 nXStart,sal_uInt16 nYStart,sal_uInt16 nDivision)2603 sal_uInt16 lcl_DrawGraphic(VirtualDevice* pVDev, const SvxNumberFormat &rFmt, sal_uInt16 nXStart,
2604 						sal_uInt16 nYStart, sal_uInt16 nDivision)
2605 {
2606 	const SvxBrushItem* pBrushItem = rFmt.GetBrush();
2607 	sal_uInt16 nRet = 0;
2608 	if(pBrushItem)
2609 	{
2610 		const Graphic* pGrf = pBrushItem->GetGraphic();
2611 		if(pGrf)
2612 		{
2613 			Size aGSize( rFmt.GetGraphicSize() );
2614 			aGSize.Width() /= nDivision;
2615 			nRet = (sal_uInt16)aGSize.Width();
2616 			aGSize.Height() /= nDivision;
2617 			pGrf->Draw( pVDev, Point(nXStart,nYStart),
2618 					pVDev->PixelToLogic( aGSize ) );
2619 		}
2620 	}
2621 	return nRet;
2622 
2623 }
2624 
2625 /*-----------------09.12.97 11:54-------------------
2626 
2627 --------------------------------------------------*/
lcl_DrawBullet(VirtualDevice * pVDev,const SvxNumberFormat & rFmt,sal_uInt16 nXStart,sal_uInt16 nYStart,const Size & rSize)2628 sal_uInt16 lcl_DrawBullet(VirtualDevice* pVDev,
2629 			const SvxNumberFormat& rFmt, sal_uInt16 nXStart,
2630 			sal_uInt16 nYStart, const Size& rSize)
2631 {
2632 	Font aTmpFont(pVDev->GetFont());
2633 
2634 	//per Uno kann es sein, dass kein Font gesetzt ist!
2635 	Font aFont(rFmt.GetBulletFont() ? *rFmt.GetBulletFont() : aTmpFont);
2636 	Size aTmpSize(rSize);
2637 	aTmpSize.Width() *= rFmt.GetBulletRelSize();
2638 	aTmpSize.Width() /= 100 ;
2639 	aTmpSize.Height() *= rFmt.GetBulletRelSize();
2640 	aTmpSize.Height() /= 100 ;
2641 	// bei einer Hoehe von Null wird in Ursprungshoehe gezeichnet
2642 	if(!aTmpSize.Height())
2643 		aTmpSize.Height() = 1;
2644 	aFont.SetSize(aTmpSize);
2645 	aFont.SetTransparent(sal_True);
2646 	Color aBulletColor = rFmt.GetBulletColor();
2647     if(aBulletColor.GetColor() == COL_AUTO)
2648         aBulletColor = Color(pVDev->GetFillColor().IsDark() ? COL_WHITE : COL_BLACK);
2649     else if(aBulletColor == pVDev->GetFillColor())
2650         aBulletColor.Invert();
2651     aFont.SetColor(aBulletColor);
2652 	pVDev->SetFont( aFont );
2653 	String aText(sal_Unicode(rFmt.GetBulletChar()));
2654 	long nY = nYStart;
2655 	nY -= ((aTmpSize.Height() - rSize.Height())/ 2);
2656 	pVDev->DrawText( Point(nXStart, nY), aText );
2657 	sal_uInt16 nRet = (sal_uInt16)pVDev->GetTextWidth(aText);
2658 
2659 	pVDev->SetFont(aTmpFont);
2660 	return nRet;
2661 }
2662 /*-----------------02.12.97 10:34-------------------
2663 	Vorschau der Numerierung painten
2664 --------------------------------------------------*/
Paint(const Rectangle &)2665 void	SvxNumberingPreview::Paint( const Rectangle& /*rRect*/ )
2666 {
2667 	Size aSize(PixelToLogic(GetOutputSizePixel()));
2668 	Rectangle aRect(Point(0,0), aSize);
2669 
2670     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2671     const Color aBackColor = rStyleSettings.GetFieldColor();
2672     const Color aTextColor = rStyleSettings.GetFieldTextColor();
2673 
2674 	VirtualDevice* pVDev = new VirtualDevice(*this);
2675 	pVDev->EnableRTL( IsRTLEnabled() );
2676 	pVDev->SetMapMode(GetMapMode());
2677 	pVDev->SetOutputSize( aSize );
2678 
2679     Color aLineColor(COL_LIGHTGRAY);
2680     if(aLineColor == aBackColor)
2681         aLineColor.Invert();
2682     pVDev->SetLineColor(aLineColor);
2683     pVDev->SetFillColor( aBackColor );
2684 	pVDev->DrawRect(aRect);
2685 
2686 	if(pActNum)
2687 	{
2688 		sal_uInt16 nWidthRelation;
2689 		if(nPageWidth)
2690 		{
2691 			nWidthRelation = sal_uInt16 (nPageWidth / aSize.Width());
2692 			if(bPosition)
2693 				nWidthRelation = nWidthRelation * 2 / 3;
2694 			else
2695 				nWidthRelation = nWidthRelation / 4;
2696 		}
2697 		else
2698 			nWidthRelation = 30; // Kapiteldialog
2699 
2700 		//Hoehe pro Ebene
2701 		sal_uInt16 nXStep = sal::static_int_cast< sal_uInt16 >(aSize.Width() / (3 * pActNum->GetLevelCount()));
2702 		if(pActNum->GetLevelCount() < 10)
2703 			nXStep /= 2;
2704 		sal_uInt16 nYStart = 4;
2705 		// fuer ein einziges Level darf nicht die gesamte Hoehe benutzt werden
2706 		sal_uInt16 nYStep = sal::static_int_cast< sal_uInt16 >((aSize.Height() - 6)/ (pActNum->GetLevelCount() > 1 ? pActNum->GetLevelCount() : 5));
2707         aStdFont = OutputDevice::GetDefaultFont(
2708                 DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE);
2709 		aStdFont.SetColor(aTextColor);
2710 		aStdFont.SetFillColor(aBackColor);
2711 
2712 		//
2713 		sal_uInt16 nFontHeight = nYStep * 6 / 10;
2714 		if(bPosition)
2715 			nFontHeight = nYStep * 15 / 10;
2716 		aStdFont.SetSize(Size( 0, nFontHeight ));
2717 
2718 		SvxNodeNum aNum( (sal_uInt8)0 );
2719 		sal_uInt16 nPreNum = pActNum->GetLevel(0).GetStart();
2720 
2721 		if(bPosition)
2722 		{
2723 			sal_uInt16 nLineHeight = nFontHeight * 8 / 7;
2724 			sal_uInt8 nStart = 0;
2725 			while( !(nActLevel & (1<<nStart)) )
2726 			{
2727 				nStart++;
2728 			}
2729 			if(nStart)
2730 				nStart--;
2731 			sal_uInt8 nEnd = std::min( (sal_uInt8)(nStart + 3), (sal_uInt8)pActNum->GetLevelCount() );
2732 			for( sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel )
2733 			{
2734 				const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel);
2735 				aNum.GetLevelVal()[ nLevel ] = rFmt.GetStart();
2736 
2737                 // --> OD 2008-01-16 #newlistlevelattrs#
2738                 sal_uInt16 nXStart( 0 );
2739                 short nTextOffset( 0 );
2740                 sal_uInt16 nNumberXPos( 0 );
2741                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2742                 {
2743                     nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
2744                     nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation;
2745                     nNumberXPos = nXStart;
2746                     sal_uInt16 nFirstLineOffset = (-rFmt.GetFirstLineOffset()) / nWidthRelation;
2747 
2748                     if(nFirstLineOffset <= nNumberXPos)
2749                         nNumberXPos = nNumberXPos - nFirstLineOffset;
2750                     else
2751                         nNumberXPos = 0;
2752                     //im draw ist das zulaeesig
2753                     if(nTextOffset < 0)
2754                         nNumberXPos = nNumberXPos + nTextOffset;
2755                 }
2756                 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
2757                 {
2758                     const long nTmpNumberXPos( ( rFmt.GetIndentAt() +
2759                                                  rFmt.GetFirstLineIndent() ) /
2760                                                nWidthRelation );
2761                     if ( nTmpNumberXPos < 0 )
2762                     {
2763                         nNumberXPos = 0;
2764                     }
2765                     else
2766                     {
2767                         nNumberXPos = static_cast<sal_uInt16>( nTmpNumberXPos );
2768                     }
2769                 }
2770                 // <--
2771 
2772 				sal_uInt16 nBulletWidth = 0;
2773 				if( SVX_NUM_BITMAP == (rFmt.GetNumberingType() &(~LINK_TOKEN)))
2774 				{
2775 					nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawGraphic(pVDev, rFmt,
2776 										nNumberXPos,
2777 											nYStart, nWidthRelation) : 0;
2778 				}
2779 				else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
2780 				{
2781 					nBulletWidth =  rFmt.IsShowSymbol() ?
2782 					 lcl_DrawBullet(pVDev, rFmt, nNumberXPos, nYStart, aStdFont.GetSize()) : 0;
2783 				}
2784 				else
2785 				{
2786 					pVDev->SetFont(aStdFont);
2787 					aNum.SetLevel( nLevel );
2788 					if(pActNum->IsContinuousNumbering())
2789 						aNum.GetLevelVal()[nLevel] = nPreNum;
2790 					String aText(pActNum->MakeNumString( aNum ));
2791 					Font aSaveFont = pVDev->GetFont();
2792 					Font aColorFont(aSaveFont);
2793                     Color aTmpBulletColor = rFmt.GetBulletColor();
2794                     if(aTmpBulletColor.GetColor() == COL_AUTO)
2795                         aTmpBulletColor = Color(aBackColor.IsDark() ? COL_WHITE : COL_BLACK);
2796                     else if(aTmpBulletColor == aBackColor)
2797                         aTmpBulletColor.Invert();
2798                     aColorFont.SetColor(aTmpBulletColor);
2799 					pVDev->SetFont(aColorFont);
2800 					pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
2801 					pVDev->SetFont(aSaveFont);
2802 					nBulletWidth = (sal_uInt16)pVDev->GetTextWidth(aText);
2803 					nPreNum++;
2804 				}
2805                 // --> OD 2008-01-16 #newlistlevelattrs#
2806                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT &&
2807                      rFmt.GetLabelFollowedBy() == SvxNumberFormat::SPACE )
2808                 {
2809                     pVDev->SetFont(aStdFont);
2810                     String aText(' ');
2811                     pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
2812                     nBulletWidth = nBulletWidth + (sal_uInt16)pVDev->GetTextWidth(aText);
2813                 }
2814 
2815                 // --> OD 2008-01-16 #newlistlevelattrs#
2816                 sal_uInt16 nTextXPos( 0 );
2817                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2818                 {
2819                     nTextXPos = nXStart;
2820                     if(nTextOffset < 0)
2821                          nTextXPos = nTextXPos + nTextOffset;
2822                     if(nNumberXPos + nBulletWidth + nTextOffset > nTextXPos )
2823                         nTextXPos = nNumberXPos + nBulletWidth + nTextOffset;
2824                 }
2825                 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
2826                 {
2827                     switch ( rFmt.GetLabelFollowedBy() )
2828                     {
2829                         case SvxNumberFormat::LISTTAB:
2830                         {
2831                             nTextXPos = static_cast<sal_uInt16>(
2832                                             rFmt.GetListtabPos() / nWidthRelation );
2833                             if ( nTextXPos < nNumberXPos + nBulletWidth )
2834                             {
2835                                 nTextXPos = nNumberXPos + nBulletWidth;
2836                             }
2837                         }
2838                         break;
2839                         case SvxNumberFormat::SPACE:
2840                         case SvxNumberFormat::NOTHING:
2841                         {
2842                             nTextXPos = nNumberXPos + nBulletWidth;
2843                         }
2844                         break;
2845                     }
2846 
2847                     nXStart = static_cast<sal_uInt16>( rFmt.GetIndentAt() / nWidthRelation );
2848                 }
2849                 // <--
2850 
2851 				Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2));
2852                 pVDev->SetFillColor( aBackColor );
2853 				pVDev->DrawRect( aRect1 );
2854 
2855 				Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2));
2856 				pVDev->DrawRect( aRect2 );
2857 				nYStart += 2 * nLineHeight;
2858 			}
2859 		}
2860 		else
2861 		{
2862             //#i5153# painting gray or black rectangles as 'normal' numbering text
2863             String sMsg( RTL_CONSTASCII_USTRINGPARAM( "Preview") );
2864             long nWidth = pVDev->GetTextWidth(sMsg);
2865             long nTextHeight = pVDev->GetTextHeight();
2866             long nRectHeight = nTextHeight * 2 / 3;
2867             long nTopOffset = nTextHeight - nRectHeight;
2868             Color aBlackColor(COL_BLACK);
2869             if(aBlackColor == aBackColor)
2870                 aBlackColor.Invert();
2871 
2872 			for( sal_uInt8 nLevel = 0; nLevel < pActNum->GetLevelCount();
2873 							++nLevel, nYStart = nYStart + nYStep )
2874 			{
2875 				const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel);
2876 				aNum.GetLevelVal()[ nLevel ] = rFmt.GetStart();
2877                 // --> OD 2008-01-31 #newlistlevelattrs#
2878                 sal_uInt16 nXStart( 0 );
2879                 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2880                 {
2881                     nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
2882                 }
2883                 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
2884                 {
2885                     const long nTmpXStart( ( rFmt.GetIndentAt() +
2886                                              rFmt.GetFirstLineIndent() ) /
2887                                            nWidthRelation );
2888                     if ( nTmpXStart < 0 )
2889                     {
2890                         nXStart = 0;
2891                     }
2892                     else
2893                     {
2894                         nXStart = static_cast<sal_uInt16>(nTmpXStart);
2895                     }
2896                 }
2897                 nXStart /= 2;
2898                 nXStart += 2;
2899                 // <--
2900 				sal_uInt16 nTextOffset = 2 * nXStep;
2901 				if( SVX_NUM_BITMAP == (rFmt.GetNumberingType()&(~LINK_TOKEN)) )
2902 				{
2903 					if(rFmt.IsShowSymbol())
2904 					{
2905 						nTextOffset = lcl_DrawGraphic(pVDev, rFmt, nXStart, nYStart, nWidthRelation);
2906 						nTextOffset = nTextOffset + nXStep;
2907 					}
2908 				}
2909 				else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
2910 				{
2911 					if(rFmt.IsShowSymbol())
2912 					{
2913 						nTextOffset =  lcl_DrawBullet(pVDev, rFmt, nXStart, nYStart, aStdFont.GetSize());
2914 						nTextOffset = nTextOffset + nXStep;
2915 					}
2916 				}
2917 				else
2918 				{
2919 					Font aColorFont(aStdFont);
2920                     Color aTmpBulletColor = rFmt.GetBulletColor();
2921                     if(aTmpBulletColor.GetColor() == COL_AUTO)
2922                         aTmpBulletColor = Color(aBackColor.IsDark() ? COL_WHITE : COL_BLACK);
2923                     else if(aTmpBulletColor == aBackColor)
2924                         aTmpBulletColor.Invert();
2925                     aColorFont.SetColor(aTmpBulletColor);
2926 					pVDev->SetFont(aColorFont);
2927 					aNum.SetLevel( nLevel );
2928 					if(pActNum->IsContinuousNumbering())
2929 						aNum.GetLevelVal()[nLevel] = nPreNum;
2930 					String aText(pActNum->MakeNumString( aNum ));
2931 					pVDev->DrawText( Point(nXStart, nYStart), aText );
2932 					pVDev->SetFont(aStdFont);
2933 					nTextOffset = (sal_uInt16)pVDev->GetTextWidth(aText);
2934 					nTextOffset = nTextOffset + nXStep;
2935 					nPreNum++;
2936 				}
2937                 if(pOutlineNames)
2938                 {
2939                     //#i5153# outline numberings still use the style names as text
2940                     pVDev->SetFont(aStdFont);
2941                     sMsg = pOutlineNames[nLevel];
2942                     pVDev->DrawText( Point(nXStart + nTextOffset, nYStart), sMsg );
2943                 }
2944                 else
2945                 {
2946                     //#i5153# the selected rectangle(s) should be black
2947                     if( 0 != (nActLevel & (1<<nLevel)))
2948                     {
2949                         pVDev->SetFillColor( aBlackColor );
2950                         pVDev->SetLineColor( aBlackColor );
2951                     }
2952                     else
2953                     {
2954                         //#i5153# unselected levels are gray
2955                         pVDev->SetFillColor( aLineColor );
2956                         pVDev->SetLineColor( aLineColor );
2957                     }
2958                     Rectangle aRect1(Point(nXStart + nTextOffset, nYStart + nTopOffset), Size(nWidth, nRectHeight));
2959                     pVDev->DrawRect(aRect1);
2960                 }
2961 			}
2962 		}
2963 	}
2964 	DrawOutDev(	Point(0,0), aSize,
2965 				Point(0,0), aSize,
2966 						*pVDev );
2967 	delete pVDev;
2968 
2969 }
2970 
2971 /*-----------------03.12.97 10:02-------------------
2972 
2973 --------------------------------------------------*/
SvxNumPositionTabPage(Window * pParent,const SfxItemSet & rSet)2974 SvxNumPositionTabPage::SvxNumPositionTabPage(Window* pParent,
2975 							   const SfxItemSet& rSet) :
2976 	SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_NUM_POSITION ), rSet ),
2977     aPositionFL(    this, CUI_RES(FL_POSITION )),
2978     aLevelFT(       this, CUI_RES(FT_LEVEL    )),
2979 	aLevelLB(		this, CUI_RES(LB_LEVEL	)),
2980 	aDistBorderFT(	this, CUI_RES(FT_BORDERDIST	)),
2981 	aDistBorderMF(	this, CUI_RES(MF_BORDERDIST	)),
2982 	aRelativeCB(	this, CUI_RES(CB_RELATIVE		)),
2983 	aIndentFT(		this, CUI_RES(FT_INDENT		)),
2984 	aIndentMF(		this, CUI_RES(MF_INDENT		)),
2985 	aDistNumFT(		this, CUI_RES(FT_NUMDIST		)),
2986 	aDistNumMF(		this, CUI_RES(MF_NUMDIST		)),
2987 	aAlignFT(		this, CUI_RES(FT_ALIGN	)),
2988 	aAlignLB(		this, CUI_RES(LB_ALIGN	)),
2989     // --> OD 2008-01-10 #newlistlevelattrs#
2990     aLabelFollowedByFT( this, CUI_RES(FT_LABEL_FOLLOWED_BY) ),
2991     aLabelFollowedByLB( this, CUI_RES(LB_LABEL_FOLLOWED_BY) ),
2992     aListtabFT( this, CUI_RES(FT_LISTTAB) ),
2993     aListtabMF( this, CUI_RES(MF_LISTTAB) ),
2994     aAlign2FT( this, CUI_RES(FT_ALIGN_2) ),
2995     aAlign2LB( this, CUI_RES(LB_ALIGN_2) ),
2996     aAlignedAtFT( this, CUI_RES(FT_ALIGNED_AT) ),
2997     aAlignedAtMF( this, CUI_RES(MF_ALIGNED_AT) ),
2998     aIndentAtFT( this, CUI_RES(FT_INDENT_AT) ),
2999     aIndentAtMF( this, CUI_RES(MF_INDENT_AT) ),
3000     // <--
3001     aStandardPB(    this, CUI_RES(PB_STANDARD       )),
3002 	pPreviewWIN(	new SvxNumberingPreview(this, CUI_RES(WIN_PREVIEW	))),
3003 	pActNum(0),
3004 	pSaveNum(0),
3005 	nActNumLvl( USHRT_MAX ),
3006 	nNumItemId(SID_ATTR_NUMBERING_RULE),
3007         bModified(false),
3008         bPreset(false),
3009     bInInintControl(sal_False),
3010     // --> OD 2008-01-11 #newlistlevelattrs#
3011     bLabelAlignmentPosAndSpaceModeActive( false )
3012     // <--
3013 {
3014 	FreeResource();
3015 	SetExchangeSupport();
3016 	pPreviewWIN->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
3017 
3018 	aRelativeCB.Check();
3019 	aAlignLB.SetSelectHdl(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl));
3020     // --> OD 2008-01-10 #newlistlevelattrs#
3021     aAlign2LB.SetSelectHdl(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl));
3022     for ( sal_uInt16 i = 0; i < aAlignLB.GetEntryCount(); ++i )
3023     {
3024         aAlign2LB.InsertEntry( aAlignLB.GetEntry( i ) );
3025     }
3026     aAlign2LB.SetDropDownLineCount( aAlign2LB.GetEntryCount() );
3027     aAlign2FT.SetText( aAlignFT.GetText() );
3028     // <--
3029 
3030 	Link aLk = LINK(this, SvxNumPositionTabPage, DistanceHdl_Impl);
3031 
3032 	aDistBorderMF.SetUpHdl(aLk);
3033 	aDistBorderMF.SetDownHdl(aLk);
3034 	aDistBorderMF.SetLoseFocusHdl(aLk);
3035 
3036 	aDistNumMF.SetUpHdl(aLk);
3037 	aDistNumMF.SetDownHdl(aLk);
3038 	aDistNumMF.SetLoseFocusHdl(aLk);
3039 
3040 	aIndentMF.SetUpHdl(aLk);
3041 	aIndentMF.SetDownHdl(aLk);
3042 	aIndentMF.SetLoseFocusHdl(aLk);
3043 
3044     // --> OD 2008-01-10 #newlistlevelattrs#
3045     aLabelFollowedByLB.SetDropDownLineCount( aLabelFollowedByLB.GetEntryCount() );
3046     aLabelFollowedByLB.SetSelectHdl( LINK(this, SvxNumPositionTabPage, LabelFollowedByHdl_Impl) );
3047 
3048     aLk = LINK(this, SvxNumPositionTabPage, ListtabPosHdl_Impl);
3049     aListtabMF.SetUpHdl(aLk);
3050     aListtabMF.SetDownHdl(aLk);
3051     aListtabMF.SetLoseFocusHdl(aLk);
3052 
3053     aLk = LINK(this, SvxNumPositionTabPage, AlignAtHdl_Impl);
3054     aAlignedAtMF.SetUpHdl(aLk);
3055     aAlignedAtMF.SetDownHdl(aLk);
3056     aAlignedAtMF.SetLoseFocusHdl(aLk);
3057 
3058     aLk = LINK(this, SvxNumPositionTabPage, IndentAtHdl_Impl);
3059     aIndentAtMF.SetUpHdl(aLk);
3060     aIndentAtMF.SetDownHdl(aLk);
3061     aIndentAtMF.SetLoseFocusHdl(aLk);
3062     // <--
3063 
3064 	aLevelLB.SetSelectHdl(LINK(this, SvxNumPositionTabPage, LevelHdl_Impl));
3065 	aRelativeCB.SetClickHdl(LINK(this, SvxNumPositionTabPage, RelativeHdl_Impl));
3066 	aStandardPB.SetClickHdl(LINK(this, SvxNumPositionTabPage, StandardHdl_Impl));
3067 
3068 
3069 	aRelativeCB.Check(bLastRelative);
3070 	pPreviewWIN->SetPositionMode();
3071 	eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
3072 
3073     //HACK("der Wert sollte mal sinnvol gesetzt werden")
3074     long nWidth = 10000;
3075     nWidth = OutputDevice::LogicToLogic( nWidth,
3076                                             (MapUnit)eCoreUnit, MAP_100TH_MM );
3077 
3078     aDistBorderMF.SetMax(aDistBorderMF.Normalize( nWidth ), FUNIT_100TH_MM );
3079     aDistNumMF   .SetMax(aDistNumMF   .Normalize( nWidth ), FUNIT_100TH_MM );
3080     aIndentMF    .SetMax(aIndentMF    .Normalize( nWidth ), FUNIT_100TH_MM );
3081     // --> OD 2008-02-18 #newlistlevelattrs#
3082     aListtabMF.SetMax(aListtabMF.Normalize( nWidth ), FUNIT_100TH_MM );
3083     aAlignedAtMF.SetMax(aAlignedAtMF.Normalize( nWidth ), FUNIT_100TH_MM );
3084     aIndentAtMF.SetMax(aIndentAtMF.Normalize( nWidth ), FUNIT_100TH_MM );
3085     // <--
3086     long nLast2 = nWidth /2;
3087     aDistBorderMF.SetLast( aDistBorderMF.Normalize(   nLast2 ), FUNIT_100TH_MM );
3088     aDistNumMF   .SetLast( aDistNumMF     .Normalize( nLast2 ), FUNIT_100TH_MM );
3089     aIndentMF    .SetLast( aIndentMF      .Normalize( nLast2 ), FUNIT_100TH_MM );
3090     // --> OD 2008-02-18 #newlistlevelattrs#
3091     aListtabMF.SetLast(aListtabMF.Normalize( nLast2 ), FUNIT_100TH_MM );
3092     aAlignedAtMF.SetLast(aAlignedAtMF.Normalize( nLast2 ), FUNIT_100TH_MM );
3093     aIndentAtMF.SetLast(aIndentAtMF.Normalize( nLast2 ), FUNIT_100TH_MM );
3094     // <--
3095 
3096 #if OSL_DEBUG_LEVEL > 1
3097 	pDebugFixedText = new FixedText(this, 0);
3098 	pDebugFixedText->Show();
3099 	Size aSize(200, 20);
3100 	Point aPos(250,0);
3101 
3102 	pDebugFixedText->SetPosSizePixel(aPos, aSize);
3103 	pDebugFixedText->SetText( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "Das ist ein Debug-Text" ) ) );
3104 #endif
3105 
3106 	aStandardPB.SetAccessibleRelationMemberOf(&aPositionFL);
3107 }
3108 /*-----------------03.12.97 10:02-------------------
3109 
3110 --------------------------------------------------*/
~SvxNumPositionTabPage()3111 SvxNumPositionTabPage::~SvxNumPositionTabPage()
3112 {
3113 	delete pActNum;
3114 	delete pPreviewWIN;
3115 	delete pSaveNum;
3116 #if OSL_DEBUG_LEVEL > 1
3117 	delete pDebugFixedText;
3118 #endif
3119 }
3120 /*-------------------------------------------------------*/
3121 
3122 #if OSL_DEBUG_LEVEL > 1
lcl_PrintDebugOutput(FixedText & rFixed,const SvxNumberFormat & rNumFmt)3123 void lcl_PrintDebugOutput(FixedText& rFixed, const SvxNumberFormat& rNumFmt)
3124 {
3125 #define TWIP_TO_MM100(TWIP) 	((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
3126 
3127 	sal_Char const sHash[] = " # ";
3128     if ( rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
3129     {
3130         String sDebugText( UniString::CreateFromInt32( TWIP_TO_MM100(rNumFmt.GetAbsLSpace() ) ) );
3131         sDebugText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( sHash ) );
3132         sDebugText += UniString::CreateFromInt32( TWIP_TO_MM100(rNumFmt.GetCharTextDistance() ) );
3133         sDebugText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( sHash ) );
3134         sDebugText += UniString::CreateFromInt32( TWIP_TO_MM100(rNumFmt.GetFirstLineOffset() ) );
3135         rFixed.SetText(sDebugText);
3136     }
3137     else if ( rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
3138     {
3139         String sDebugText( UniString::CreateFromInt32( TWIP_TO_MM100(rNumFmt.GetListtabPos() ) ) );
3140         sDebugText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( sHash ) );
3141         sDebugText += UniString::CreateFromInt32( TWIP_TO_MM100(rNumFmt.GetFirstLineIndent() ) );
3142         sDebugText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( sHash ) );
3143         sDebugText += UniString::CreateFromInt32( TWIP_TO_MM100(rNumFmt.GetIndentAt() ) );
3144         rFixed.SetText(sDebugText);
3145     }
3146 
3147 }
3148 #endif
3149 
3150 /*-----------------03.12.97 10:06-------------------
3151 
3152 --------------------------------------------------*/
InitControls()3153 void SvxNumPositionTabPage::InitControls()
3154 {
3155 	bInInintControl	= sal_True;
3156     // --> OD 2008-01-11 #newlistlevelattrs#
3157     const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive &&
3158                      aRelativeCB.IsEnabled() && aRelativeCB.IsChecked();
3159     // <--
3160     const bool bSingleSelection = aLevelLB.GetSelectEntryCount() == 1 &&
3161                             USHRT_MAX != nActNumLvl;
3162 
3163     aDistBorderMF.Enable( !bLabelAlignmentPosAndSpaceModeActive &&
3164                           ( bSingleSelection || bRelative ) );
3165     aDistBorderFT.Enable( !bLabelAlignmentPosAndSpaceModeActive &&
3166                           ( bSingleSelection || bRelative ) );
3167 
3168     bool bSetDistEmpty = false;
3169     bool bSameDistBorderNum = !bLabelAlignmentPosAndSpaceModeActive;
3170     bool bSameDist      = !bLabelAlignmentPosAndSpaceModeActive;
3171     bool bSameIndent    = !bLabelAlignmentPosAndSpaceModeActive;
3172     bool bSameAdjust    = true;
3173 
3174     // --> OD 2008-01-11 #newlistlevelattrs#
3175     bool bSameLabelFollowedBy = bLabelAlignmentPosAndSpaceModeActive;
3176     bool bSameListtab = bLabelAlignmentPosAndSpaceModeActive;
3177     bool bSameAlignAt = bLabelAlignmentPosAndSpaceModeActive;
3178     bool bSameIndentAt = bLabelAlignmentPosAndSpaceModeActive;
3179     // <--
3180 
3181 	const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
3182 	sal_uInt16 nMask = 1;
3183 	sal_uInt16 nLvl = USHRT_MAX;
3184 	long nFirstBorderText = 0;
3185 	long nFirstBorderTextRelative = -1;
3186 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3187 	{
3188 		aNumFmtArr[i] = &pActNum->GetLevel(i);
3189 		if(nActNumLvl & nMask)
3190 		{
3191 			if(USHRT_MAX == nLvl)
3192 			{
3193 				nLvl = i;
3194                 if ( !bLabelAlignmentPosAndSpaceModeActive )
3195                 {
3196                     nFirstBorderText = nLvl > 0 ?
3197                         aNumFmtArr[nLvl]->GetAbsLSpace() + aNumFmtArr[nLvl]->GetFirstLineOffset() -
3198                         aNumFmtArr[nLvl - 1]->GetAbsLSpace() + aNumFmtArr[nLvl - 1]->GetFirstLineOffset():
3199                             aNumFmtArr[nLvl]->GetAbsLSpace() + aNumFmtArr[nLvl]->GetFirstLineOffset();
3200                 }
3201 			}
3202 
3203 			if( i > nLvl)
3204 			{
3205                 // --> OD 2008-01-11 #newlistlevelattrs#
3206                 bSameAdjust &= aNumFmtArr[i]->GetNumAdjust() == aNumFmtArr[nLvl]->GetNumAdjust();
3207                 if ( !bLabelAlignmentPosAndSpaceModeActive )
3208                 {
3209                     if(bRelative)
3210                     {
3211                         if(nFirstBorderTextRelative == -1)
3212                             nFirstBorderTextRelative =
3213                             (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
3214                             aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
3215                         else
3216                             bSameDistBorderNum &= nFirstBorderTextRelative ==
3217                             (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
3218                             aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
3219                     }
3220                     else
3221                         bSameDistBorderNum &=
3222                         aNumFmtArr[i]->GetAbsLSpace() - aNumFmtArr[i]->GetFirstLineOffset() ==
3223                         aNumFmtArr[i - 1]->GetAbsLSpace() - aNumFmtArr[i - 1]->GetFirstLineOffset();
3224 
3225                     bSameDist       &= aNumFmtArr[i]->GetCharTextDistance() == aNumFmtArr[nLvl]->GetCharTextDistance();
3226                     bSameIndent     &= aNumFmtArr[i]->GetFirstLineOffset() == aNumFmtArr[nLvl]->GetFirstLineOffset();
3227                 }
3228                 else
3229                 {
3230                     bSameLabelFollowedBy &=
3231                         aNumFmtArr[i]->GetLabelFollowedBy() == aNumFmtArr[nLvl]->GetLabelFollowedBy();
3232                     bSameListtab &=
3233                         aNumFmtArr[i]->GetListtabPos() == aNumFmtArr[nLvl]->GetListtabPos();
3234                     bSameAlignAt &=
3235                         ( ( aNumFmtArr[i]->GetIndentAt() + aNumFmtArr[i]->GetFirstLineIndent() )
3236                             == ( aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent() ) );
3237                     bSameIndentAt &=
3238                         aNumFmtArr[i]->GetIndentAt() == aNumFmtArr[nLvl]->GetIndentAt();
3239                 }
3240                 // <--
3241 			}
3242 		}
3243 		nMask <<= 1;
3244 
3245 	}
3246     if (SVX_MAX_NUM <= nLvl)
3247     {
3248         OSL_ENSURE(false, "cannot happen.");
3249         return;
3250     }
3251 
3252 	if(bSameDistBorderNum)
3253 	{
3254 		long nDistBorderNum;
3255 		if(bRelative)
3256 		{
3257 			nDistBorderNum = (long)aNumFmtArr[nLvl]->GetAbsLSpace()+ aNumFmtArr[nLvl]->GetFirstLineOffset();
3258 			if(nLvl)
3259 				nDistBorderNum -= (long)aNumFmtArr[nLvl - 1]->GetAbsLSpace()+ aNumFmtArr[nLvl - 1]->GetFirstLineOffset();
3260 		}
3261 		else
3262 		{
3263 			nDistBorderNum = (long)aNumFmtArr[nLvl]->GetAbsLSpace()+ aNumFmtArr[nLvl]->GetFirstLineOffset();
3264 		}
3265 		SetMetricValue(aDistBorderMF, nDistBorderNum, eCoreUnit);
3266 	}
3267 	else
3268         bSetDistEmpty = true;
3269 
3270 #if OSL_DEBUG_LEVEL > 1
3271 	lcl_PrintDebugOutput(*pDebugFixedText, *aNumFmtArr[nLvl]);
3272 #endif
3273 
3274     const String aEmptyStr;
3275 	if(bSameDist)
3276 		SetMetricValue(aDistNumMF, aNumFmtArr[nLvl]->GetCharTextDistance(), eCoreUnit);
3277 	else
3278 		aDistNumMF.SetText(aEmptyStr);
3279 	if(bSameIndent)
3280 		SetMetricValue(aIndentMF, - aNumFmtArr[nLvl]->GetFirstLineOffset(), eCoreUnit);
3281 	else
3282 		aIndentMF.SetText(aEmptyStr);
3283 
3284 	if(bSameAdjust)
3285 	{
3286 		sal_uInt16 nPos = 1; // zentriert
3287 		if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_LEFT)
3288 			nPos = 0;
3289 		else if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_RIGHT)
3290 			nPos = 2;
3291 		aAlignLB.SelectEntryPos(nPos);
3292         // --> OD 2008-01-11 #newlistlevelattrs#
3293         aAlign2LB.SelectEntryPos( nPos );
3294         // <--
3295 	}
3296 	else
3297 	{
3298 		aAlignLB.SetNoSelection();
3299         // --> OD 2008-01-11 #newlistlevelattrs#
3300         aAlign2LB.SetNoSelection();
3301         // <--
3302 	}
3303 
3304     // --> OD 2008-01-11 #newlistlevelattrs#
3305     if ( bSameLabelFollowedBy )
3306     {
3307         sal_uInt16 nPos = 0; // LISTTAB
3308         if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::SPACE )
3309         {
3310             nPos = 1;
3311         }
3312         else if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING )
3313         {
3314             nPos = 2;
3315         }
3316         aLabelFollowedByLB.SelectEntryPos( nPos );
3317     }
3318     else
3319     {
3320         aLabelFollowedByLB.SetNoSelection();
3321     }
3322 
3323     if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
3324     {
3325         aListtabFT.Enable( true );
3326         aListtabMF.Enable( true );
3327         if ( bSameListtab )
3328         {
3329             SetMetricValue( aListtabMF, aNumFmtArr[nLvl]->GetListtabPos(), eCoreUnit );
3330         }
3331         else
3332         {
3333             aListtabMF.SetText(aEmptyStr);
3334         }
3335     }
3336     else
3337     {
3338         aListtabFT.Enable( false );
3339         aListtabMF.Enable( false );
3340         aListtabMF.SetText(aEmptyStr);
3341     }
3342 
3343     if ( bSameAlignAt )
3344     {
3345         SetMetricValue( aAlignedAtMF,
3346                         aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent(),
3347                         eCoreUnit );
3348     }
3349     else
3350     {
3351         aAlignedAtMF.SetText(aEmptyStr);
3352     }
3353 
3354     if ( bSameIndentAt )
3355     {
3356         SetMetricValue( aIndentAtMF, aNumFmtArr[nLvl]->GetIndentAt(), eCoreUnit );
3357     }
3358     else
3359     {
3360         aIndentAtMF.SetText(aEmptyStr);
3361     }
3362     // <--
3363 
3364     if ( bSetDistEmpty )
3365 		aDistBorderMF.SetText(aEmptyStr);
3366 
3367 	bInInintControl	= sal_False;
3368 }
3369 
3370 /*-----------------03.12.97 10:02-------------------
3371 
3372 --------------------------------------------------*/
ActivatePage(const SfxItemSet & rSet)3373 void SvxNumPositionTabPage::ActivatePage(const SfxItemSet& rSet)
3374 {
3375 	const SfxPoolItem* pItem;
3376 	sal_uInt16 nTmpNumLvl = USHRT_MAX;
3377 	const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
3378 	if(pExampleSet)
3379 	{
3380 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
3381 			bPreset = ((const SfxBoolItem*)pItem)->GetValue();
3382 		if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
3383 			nTmpNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
3384 	}
3385 	//
3386 	if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
3387 	{
3388 		delete pSaveNum;
3389 		pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
3390 	}
3391 	bModified = (!pActNum->Get( 0 ) || bPreset);
3392 	if(*pSaveNum != *pActNum ||
3393 		nActNumLvl != nTmpNumLvl )
3394 	{
3395 		*pActNum = *pSaveNum;
3396 		nActNumLvl = nTmpNumLvl;
3397 		sal_uInt16 nMask = 1;
3398 		aLevelLB.SetUpdateMode(sal_False);
3399 		aLevelLB.SetNoSelection();
3400 		aLevelLB.SelectEntryPos( pActNum->GetLevelCount(), nActNumLvl == USHRT_MAX);
3401 		if(nActNumLvl != USHRT_MAX)
3402 			for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3403 			{
3404 				if(nActNumLvl & nMask)
3405 					aLevelLB.SelectEntryPos( i, sal_True);
3406 				nMask <<= 1 ;
3407 			}
3408 		aRelativeCB.Enable(nActNumLvl != 1);
3409 		aLevelLB.SetUpdateMode(sal_True);
3410 
3411         // --> OD 2008-01-11 #newlistlevelattrs#
3412         InitPosAndSpaceMode();
3413         ShowControlsDependingOnPosAndSpaceMode();
3414         // <--
3415 
3416         InitControls();
3417 	}
3418 	pPreviewWIN->SetLevel(nActNumLvl);
3419 	pPreviewWIN->Invalidate();
3420 }
3421 
3422 /*-----------------03.12.97 10:02-------------------
3423 
3424 --------------------------------------------------*/
DeactivatePage(SfxItemSet * _pSet)3425 int  SvxNumPositionTabPage::DeactivatePage(SfxItemSet *_pSet)
3426 {
3427 	if(_pSet)
3428 		FillItemSet(*_pSet);
3429 	return sal_True;
3430 }
3431 
3432 /*-----------------03.12.97 10:02-------------------
3433 
3434 --------------------------------------------------*/
FillItemSet(SfxItemSet & rSet)3435 sal_Bool SvxNumPositionTabPage::FillItemSet( SfxItemSet& rSet )
3436 {
3437 	rSet.Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
3438 
3439     if(bModified && pActNum)
3440 	{
3441 		*pSaveNum = *pActNum;
3442 		rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
3443 		rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, sal_False));
3444 	}
3445 	return bModified;
3446 }
3447 
3448 /*-----------------03.12.97 10:02-------------------
3449 
3450 --------------------------------------------------*/
Reset(const SfxItemSet & rSet)3451 void SvxNumPositionTabPage::Reset( const SfxItemSet& rSet )
3452 {
3453 	const SfxPoolItem* pItem;
3454 	//im Draw gibt es das Item als WhichId, im Writer nur als SlotId
3455 	SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
3456 	if(eState != SFX_ITEM_SET)
3457 	{
3458 		nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
3459 		eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
3460 
3461 		if( eState != SFX_ITEM_SET )
3462 		{
3463 	        pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
3464 	        eState = SFX_ITEM_SET;
3465 		}
3466 
3467 	}
3468 	DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
3469 	delete pSaveNum;
3470 	pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
3471 
3472 	// Ebenen einfuegen
3473 	if(!aLevelLB.GetEntryCount())
3474 	{
3475 		for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
3476 			aLevelLB.InsertEntry(UniString::CreateFromInt32(i));
3477 		if(pSaveNum->GetLevelCount() > 1)
3478 		{
3479 			String sEntry( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "1 - ") ) );
3480 			sEntry.Append( UniString::CreateFromInt32( pSaveNum->GetLevelCount() ) );
3481 			aLevelLB.InsertEntry(sEntry);
3482 			aLevelLB.SelectEntry(sEntry);
3483 		}
3484 		else
3485 			aLevelLB.SelectEntryPos(0);
3486 	}
3487 	else
3488 		aLevelLB.SelectEntryPos(aLevelLB.GetEntryCount() - 1);
3489 	sal_uInt16 nMask = 1;
3490 	aLevelLB.SetUpdateMode(sal_False);
3491 	aLevelLB.SetNoSelection();
3492 	if(nActNumLvl == USHRT_MAX)
3493 	{
3494 		aLevelLB.SelectEntryPos( pSaveNum->GetLevelCount(), sal_True);
3495 	}
3496 	else
3497 		for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
3498 		{
3499 			if(nActNumLvl & nMask)
3500 				aLevelLB.SelectEntryPos( i, sal_True);
3501 			nMask <<= 1;
3502 		}
3503 	aLevelLB.SetUpdateMode(sal_True);
3504 
3505 	if(!pActNum)
3506 		pActNum = new  SvxNumRule(*pSaveNum);
3507 	else if(*pSaveNum != *pActNum)
3508 		*pActNum = *pSaveNum;
3509 	pPreviewWIN->SetNumRule(pActNum);
3510 
3511     // --> OD 2008-01-11 #newlistlevelattrs#
3512     InitPosAndSpaceMode();
3513     ShowControlsDependingOnPosAndSpaceMode();
3514 //    const sal_Bool bDraw = pActNum->IsFeatureSupported(NUM_CONTINUOUS);
3515 //    aDistNumFT.Show(bDraw);
3516 //    aDistNumMF.Show(bDraw);
3517     // <--
3518 
3519 	InitControls();
3520 	bModified = sal_False;
3521 }
3522 
3523 // --> OD 2008-01-11 #newlistlevelattrs#
InitPosAndSpaceMode()3524 void SvxNumPositionTabPage::InitPosAndSpaceMode()
3525 {
3526     if ( pActNum == 0 )
3527     {
3528         DBG_ASSERT( false,
3529                 "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
3530         return;
3531     }
3532 
3533     SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode =
3534                                             SvxNumberFormat::LABEL_ALIGNMENT;
3535     sal_uInt16 nMask = 1;
3536     for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3537     {
3538         if(nActNumLvl & nMask)
3539         {
3540             SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3541             ePosAndSpaceMode = aNumFmt.GetPositionAndSpaceMode();
3542             if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
3543             {
3544                 break;
3545             }
3546         }
3547         nMask <<= 1;
3548     }
3549 
3550     bLabelAlignmentPosAndSpaceModeActive =
3551                     ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT;
3552 }
3553 
ShowControlsDependingOnPosAndSpaceMode()3554 void SvxNumPositionTabPage::ShowControlsDependingOnPosAndSpaceMode()
3555 {
3556     aDistBorderFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
3557     aDistBorderMF.Show( !bLabelAlignmentPosAndSpaceModeActive );
3558     aRelativeCB.Show( !bLabelAlignmentPosAndSpaceModeActive );
3559     aIndentFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
3560     aIndentMF.Show( !bLabelAlignmentPosAndSpaceModeActive );
3561     aDistNumFT.Show( !bLabelAlignmentPosAndSpaceModeActive &&
3562                      pActNum->IsFeatureSupported(NUM_CONTINUOUS) );
3563     aDistNumMF.Show( !bLabelAlignmentPosAndSpaceModeActive &&
3564                      pActNum->IsFeatureSupported(NUM_CONTINUOUS));
3565     aAlignFT.Show( !bLabelAlignmentPosAndSpaceModeActive );
3566     aAlignLB.Show( !bLabelAlignmentPosAndSpaceModeActive );
3567 
3568     aLabelFollowedByFT.Show( bLabelAlignmentPosAndSpaceModeActive );
3569     aLabelFollowedByLB.Show( bLabelAlignmentPosAndSpaceModeActive );
3570     aListtabFT.Show( bLabelAlignmentPosAndSpaceModeActive );
3571     aListtabMF.Show( bLabelAlignmentPosAndSpaceModeActive );
3572     aAlign2FT.Show( bLabelAlignmentPosAndSpaceModeActive );
3573     aAlign2LB.Show( bLabelAlignmentPosAndSpaceModeActive );
3574     aAlignedAtFT.Show( bLabelAlignmentPosAndSpaceModeActive );
3575     aAlignedAtMF.Show( bLabelAlignmentPosAndSpaceModeActive );
3576     aIndentAtFT.Show( bLabelAlignmentPosAndSpaceModeActive );
3577     aIndentAtMF.Show( bLabelAlignmentPosAndSpaceModeActive );
3578 }
3579 // <--
3580 
3581 /*-----------------03.12.97 10:02-------------------
3582 
3583 --------------------------------------------------*/
Create(Window * pParent,const SfxItemSet & rAttrSet)3584 SfxTabPage*	SvxNumPositionTabPage::Create( Window* pParent,
3585 								const SfxItemSet& rAttrSet)
3586 {
3587 	return new SvxNumPositionTabPage(pParent, rAttrSet);
3588 }
3589 
3590 /*-----------------04.12.97 12:51-------------------
3591 
3592 --------------------------------------------------*/
SetMetric(FieldUnit eMetric)3593 void	SvxNumPositionTabPage::SetMetric(FieldUnit eMetric)
3594 {
3595 	if(eMetric == FUNIT_MM)
3596 	{
3597 		aDistBorderMF .SetDecimalDigits(1);
3598 		aDistNumMF	  .SetDecimalDigits(1);
3599 		aIndentMF	  .SetDecimalDigits(1);
3600         // --> OD 2008-02-18 #newlistlevelattrs#
3601         aListtabMF.SetDecimalDigits(1);
3602         aAlignedAtMF.SetDecimalDigits(1);
3603         aIndentAtMF.SetDecimalDigits(1);
3604         // <--
3605 	}
3606 	aDistBorderMF .SetUnit( eMetric );
3607 	aDistNumMF	  .SetUnit( eMetric );
3608 	aIndentMF	  .SetUnit( eMetric );
3609     // --> OD 2008-02-18 #newlistlevelattrs#
3610     aListtabMF.SetUnit( eMetric );
3611     aAlignedAtMF.SetUnit( eMetric );
3612     aIndentAtMF.SetUnit( eMetric );
3613     // <--
3614 }
3615 
3616 /*-----------------03.12.97 11:06-------------------
3617 
3618 --------------------------------------------------*/
IMPL_LINK(SvxNumPositionTabPage,EditModifyHdl_Impl,Edit *,EMPTYARG)3619 IMPL_LINK( SvxNumPositionTabPage, EditModifyHdl_Impl, Edit *, EMPTYARG )
3620 {
3621 	sal_uInt16 nMask = 1;
3622 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3623 	{
3624 		if(nActNumLvl & nMask)
3625 		{
3626 			SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
3627 
3628             // --> OD 2008-01-11 #newlistlevelattrs#
3629             const sal_uInt16 nPos = aAlignLB.IsVisible()
3630                                 ? aAlignLB.GetSelectEntryPos()
3631                                 : aAlign2LB.GetSelectEntryPos();
3632             // <--
3633 			SvxAdjust eAdjust = SVX_ADJUST_CENTER;
3634 			if(nPos == 0)
3635 				eAdjust = SVX_ADJUST_LEFT;
3636 			else if(nPos == 2)
3637 				eAdjust = SVX_ADJUST_RIGHT;
3638 			aNumFmt.SetNumAdjust( eAdjust );
3639 			pActNum->SetLevel(i, aNumFmt);
3640 		}
3641 		nMask <<= 1;
3642 	}
3643 	SetModified();
3644 	return 0;
3645 }
3646 /*-----------------03.12.97 11:11-------------------
3647 
3648 --------------------------------------------------*/
IMPL_LINK(SvxNumPositionTabPage,LevelHdl_Impl,ListBox *,pBox)3649 IMPL_LINK( SvxNumPositionTabPage, LevelHdl_Impl, ListBox *, pBox )
3650 {
3651 	sal_uInt16 nSaveNumLvl = nActNumLvl;
3652 	nActNumLvl = 0;
3653 	if(pBox->IsEntryPosSelected( pActNum->GetLevelCount() ) &&
3654 			(pBox->GetSelectEntryCount() == 1 || nSaveNumLvl != 0xffff))
3655 	{
3656 		nActNumLvl = 0xFFFF;
3657 		pBox->SetUpdateMode(sal_False);
3658 		for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
3659 			pBox->SelectEntryPos( i, sal_False );
3660 		pBox->SetUpdateMode(sal_True);
3661 	}
3662 	else if(pBox->GetSelectEntryCount())
3663 	{
3664 		sal_uInt16 nMask = 1;
3665 		for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
3666 		{
3667 			if(pBox->IsEntryPosSelected( i ))
3668 				nActNumLvl |= nMask;
3669 			nMask <<= 1;
3670 		}
3671 		pBox->SelectEntryPos( pActNum->GetLevelCount(), sal_False );
3672 	}
3673 	else
3674 	{
3675 		nActNumLvl = nSaveNumLvl;
3676 		sal_uInt16 nMask = 1;
3677 		for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
3678 		{
3679 			if(nActNumLvl & nMask)
3680 			{
3681 				pBox->SelectEntryPos(i);
3682 				break;
3683 			}
3684 			nMask <<=1;
3685 		}
3686 	}
3687 	aRelativeCB.Enable(nActNumLvl != 1);
3688 	SetModified();
3689     // --> OD 2008-01-15 #newlistlevelattrs#
3690     InitPosAndSpaceMode();
3691     ShowControlsDependingOnPosAndSpaceMode();
3692     // <--
3693 	InitControls();
3694 	return 0;
3695 }
3696 /*-----------------03.12.97 12:24-------------------
3697 
3698 --------------------------------------------------*/
IMPL_LINK(SvxNumPositionTabPage,DistanceHdl_Impl,MetricField *,pFld)3699 IMPL_LINK( SvxNumPositionTabPage, DistanceHdl_Impl, MetricField *, pFld )
3700 {
3701 	if(bInInintControl)
3702 		return 0;
3703 	long nValue = GetCoreValue(*pFld, eCoreUnit);
3704 	sal_uInt16 nMask = 1;
3705 #if OSL_DEBUG_LEVEL > 1
3706 	sal_Bool bFirst = sal_True;
3707 #endif
3708 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3709 	{
3710 		if(nActNumLvl & nMask)
3711 		{
3712 			SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) );
3713 			if(pFld == &aDistBorderMF)
3714 			{
3715 
3716 				if(aRelativeCB.IsChecked())
3717 				{
3718 					if(0 == i)
3719 					{
3720 						long nTmp = aNumFmt.GetFirstLineOffset();
3721 						aNumFmt.SetAbsLSpace( sal_uInt16(nValue - nTmp));
3722 					}
3723 					else
3724 					{
3725 						long nTmp = pActNum->GetLevel( i - 1 ).GetAbsLSpace() +
3726 									pActNum->GetLevel( i - 1 ).GetFirstLineOffset() -
3727 									pActNum->GetLevel( i ).GetFirstLineOffset();
3728 
3729 						aNumFmt.SetAbsLSpace( sal_uInt16(nValue + nTmp));
3730 					}
3731 				}
3732 				else
3733 				{
3734 					aNumFmt.SetAbsLSpace( (short)nValue - aNumFmt.GetFirstLineOffset());
3735 				}
3736 			}
3737 			else if(pFld == &aDistNumMF)
3738 			{
3739 				aNumFmt.SetCharTextDistance( (short)nValue );
3740 			}
3741 			else if(pFld == &aIndentMF)
3742 			{
3743 				//jetzt muss mit dem FirstLineOffset auch der AbsLSpace veraendert werden
3744 				long nDiff = nValue + aNumFmt.GetFirstLineOffset();
3745 				long nAbsLSpace = aNumFmt.GetAbsLSpace();
3746 				aNumFmt.SetAbsLSpace(sal_uInt16(nAbsLSpace + nDiff));
3747 				aNumFmt.SetFirstLineOffset( -(short)nValue );
3748 			}
3749 
3750 #if OSL_DEBUG_LEVEL > 1
3751 			if(bFirst)
3752 				lcl_PrintDebugOutput(*pDebugFixedText, aNumFmt);
3753 			bFirst = sal_False;
3754 #endif
3755 			pActNum->SetLevel( i, aNumFmt );
3756 		}
3757 		nMask <<= 1;
3758 	}
3759 
3760 	SetModified();
3761 	if(!aDistBorderMF.IsEnabled())
3762 	{
3763 		String aEmptyStr;
3764 		aDistBorderMF.SetText(aEmptyStr);
3765 	}
3766 
3767 	return 0;
3768 }
3769 
3770 /*-----------------04.12.97 12:35-------------------
3771 
3772 --------------------------------------------------*/
IMPL_LINK(SvxNumPositionTabPage,RelativeHdl_Impl,CheckBox *,pBox)3773 IMPL_LINK( SvxNumPositionTabPage, RelativeHdl_Impl, CheckBox *, pBox )
3774 {
3775 	sal_Bool bOn = pBox->IsChecked();
3776 	sal_Bool bSingleSelection = aLevelLB.GetSelectEntryCount() == 1 && USHRT_MAX != nActNumLvl;
3777 	sal_Bool bSetValue = sal_False;
3778 	long nValue = 0;
3779 	if(bOn || bSingleSelection)
3780 	{
3781 		sal_uInt16 nMask = 1;
3782 		sal_Bool bFirst = sal_True;
3783 		bSetValue = sal_True;
3784 		for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3785 		{
3786 			if(nActNumLvl & nMask)
3787 			{
3788 				const SvxNumberFormat &rNumFmt = pActNum->GetLevel(i);
3789 				if(bFirst)
3790 				{
3791 					nValue = rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset();
3792 					if(bOn && i)
3793 						nValue -= (pActNum->GetLevel(i - 1).GetAbsLSpace() + pActNum->GetLevel(i - 1).GetFirstLineOffset());
3794 				}
3795 				else
3796 					bSetValue = nValue ==
3797 						(rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset()) -
3798 							(pActNum->GetLevel(i - 1).GetAbsLSpace() + pActNum->GetLevel(i - 1).GetFirstLineOffset());
3799 				bFirst = sal_False;
3800 			}
3801 			nMask <<= 1;
3802 		}
3803 
3804 	}
3805 	String aEmptyStr;
3806 	if(bSetValue)
3807 		SetMetricValue(aDistBorderMF, nValue,	eCoreUnit);
3808 	else
3809 		aDistBorderMF.SetText(aEmptyStr);
3810 	aDistBorderMF.Enable(bOn || bSingleSelection);
3811 	aDistBorderFT.Enable(bOn || bSingleSelection);
3812 	bLastRelative = bOn;
3813 	return 0;
3814 }
3815 
3816 // --> OD 2008-01-14 #newlistlevelattrs#
IMPL_LINK(SvxNumPositionTabPage,LabelFollowedByHdl_Impl,ListBox *,EMPTYARG)3817 IMPL_LINK( SvxNumPositionTabPage, LabelFollowedByHdl_Impl, ListBox*, EMPTYARG )
3818 {
3819     // determine value to be set at the chosen list levels
3820     SvxNumberFormat::SvxNumLabelFollowedBy eLabelFollowedBy =
3821                                                     SvxNumberFormat::LISTTAB;
3822     {
3823         const sal_uInt16 nPos = aLabelFollowedByLB.GetSelectEntryPos();
3824         if ( nPos == 1 )
3825         {
3826             eLabelFollowedBy = SvxNumberFormat::SPACE;
3827         }
3828         else if ( nPos == 2 )
3829         {
3830             eLabelFollowedBy = SvxNumberFormat::NOTHING;
3831         }
3832     }
3833 
3834     // set value at the chosen list levels
3835     bool bSameListtabPos = true;
3836     sal_uInt16 nFirstLvl = USHRT_MAX;
3837     sal_uInt16 nMask = 1;
3838     for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3839     {
3840         if ( nActNumLvl & nMask )
3841         {
3842             SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3843             aNumFmt.SetLabelFollowedBy( eLabelFollowedBy );
3844             pActNum->SetLevel( i, aNumFmt );
3845 
3846             if ( nFirstLvl == USHRT_MAX )
3847             {
3848                 nFirstLvl = i;
3849             }
3850             else
3851             {
3852                 bSameListtabPos &= aNumFmt.GetListtabPos() ==
3853                         pActNum->GetLevel( nFirstLvl ).GetListtabPos();
3854             }
3855         }
3856         nMask <<= 1;
3857     }
3858 
3859     // enable/disable metric field for list tab stop position depending on
3860     // selected item following the list label.
3861     aListtabFT.Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
3862     aListtabMF.Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
3863     if ( bSameListtabPos && eLabelFollowedBy == SvxNumberFormat::LISTTAB )
3864     {
3865         SetMetricValue( aListtabMF, pActNum->GetLevel( nFirstLvl ).GetListtabPos(), eCoreUnit );
3866     }
3867     else
3868     {
3869         aListtabMF.SetText( String() );
3870     }
3871 
3872     SetModified();
3873 
3874     return 0;
3875 }
3876 // <--
3877 
3878 // --> OD 2008-01-14 #newlistlevelattrs#
IMPL_LINK(SvxNumPositionTabPage,ListtabPosHdl_Impl,MetricField *,pFld)3879 IMPL_LINK( SvxNumPositionTabPage, ListtabPosHdl_Impl, MetricField*, pFld )
3880 {
3881     // determine value to be set at the chosen list levels
3882     const long nValue = GetCoreValue( *pFld, eCoreUnit );
3883 
3884     // set value at the chosen list levels
3885     sal_uInt16 nMask = 1;
3886     for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3887     {
3888         if ( nActNumLvl & nMask )
3889         {
3890             SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3891             aNumFmt.SetListtabPos( nValue );
3892             pActNum->SetLevel( i, aNumFmt );
3893 #if OSL_DEBUG_LEVEL > 1
3894             lcl_PrintDebugOutput(*pDebugFixedText, aNumFmt);
3895 #endif
3896         }
3897         nMask <<= 1;
3898     }
3899 
3900     SetModified();
3901 
3902     return 0;
3903 }
3904 // <--
3905 
3906 // --> OD 2008-01-14 #newlistlevelattrs#
IMPL_LINK(SvxNumPositionTabPage,AlignAtHdl_Impl,MetricField *,pFld)3907 IMPL_LINK( SvxNumPositionTabPage, AlignAtHdl_Impl, MetricField*, pFld )
3908 {
3909     // determine value to be set at the chosen list levels
3910     const long nValue = GetCoreValue( *pFld, eCoreUnit );
3911 
3912     // set value at the chosen list levels
3913     sal_uInt16 nMask = 1;
3914     for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3915     {
3916         if ( nActNumLvl & nMask )
3917         {
3918             SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3919             const long nFirstLineIndent = nValue - aNumFmt.GetIndentAt();
3920             aNumFmt.SetFirstLineIndent( nFirstLineIndent );
3921             pActNum->SetLevel( i, aNumFmt );
3922 #if OSL_DEBUG_LEVEL > 1
3923             lcl_PrintDebugOutput(*pDebugFixedText, aNumFmt);
3924 #endif
3925         }
3926         nMask <<= 1;
3927     }
3928 
3929     SetModified();
3930 
3931     return 0;
3932 }
3933 // <--
3934 
3935 // --> OD 2008-01-14 #newlistlevelattrs#
IMPL_LINK(SvxNumPositionTabPage,IndentAtHdl_Impl,MetricField *,pFld)3936 IMPL_LINK( SvxNumPositionTabPage, IndentAtHdl_Impl, MetricField*, pFld )
3937 {
3938     // determine value to be set at the chosen list levels
3939     const long nValue = GetCoreValue( *pFld, eCoreUnit );
3940 
3941     // set value at the chosen list levels
3942     sal_uInt16 nMask = 1;
3943     for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3944     {
3945         if ( nActNumLvl & nMask )
3946         {
3947             SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3948             const long nAlignedAt = aNumFmt.GetIndentAt() +
3949                                     aNumFmt.GetFirstLineIndent();
3950             aNumFmt.SetIndentAt( nValue );
3951             const long nNewFirstLineIndent = nAlignedAt - nValue;
3952             aNumFmt.SetFirstLineIndent( nNewFirstLineIndent );
3953             pActNum->SetLevel( i, aNumFmt );
3954 #if OSL_DEBUG_LEVEL > 1
3955             lcl_PrintDebugOutput(*pDebugFixedText, aNumFmt);
3956 #endif
3957         }
3958         nMask <<= 1;
3959     }
3960 
3961     SetModified();
3962 
3963     return 0;
3964 }
3965 // <--
3966 /*-----------------05.12.97 15:33-------------------
3967 
3968 --------------------------------------------------*/
IMPL_LINK(SvxNumPositionTabPage,StandardHdl_Impl,PushButton *,EMPTYARG)3969 IMPL_LINK( SvxNumPositionTabPage, StandardHdl_Impl, PushButton *, EMPTYARG )
3970 {
3971 	sal_uInt16 nMask = 1;
3972     // --> OD 2008-02-11 #newlistlevelattrs#
3973     SvxNumRule aTmpNumRule( pActNum->GetFeatureFlags(),
3974                             pActNum->GetLevelCount(),
3975                             pActNum->IsContinuousNumbering(),
3976                             SVX_RULETYPE_NUMBERING,
3977                             pActNum->GetLevel( 0 ).GetPositionAndSpaceMode() );
3978     // <--
3979 	for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3980 	{
3981 		if(nActNumLvl & nMask)
3982 		{
3983 			SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) );
3984 			SvxNumberFormat aTempFmt(aTmpNumRule.GetLevel( i ));
3985             // --> OD 2008-02-05 #newlistlevelattrs#
3986             aNumFmt.SetPositionAndSpaceMode( aTempFmt.GetPositionAndSpaceMode() );
3987             if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
3988             {
3989                 aNumFmt.SetAbsLSpace( aTempFmt.GetAbsLSpace() );
3990                 aNumFmt.SetCharTextDistance( aTempFmt.GetCharTextDistance() );
3991                 aNumFmt.SetFirstLineOffset( aTempFmt.GetFirstLineOffset() );
3992             }
3993             else if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
3994             {
3995                 aNumFmt.SetNumAdjust( aTempFmt.GetNumAdjust() );
3996                 aNumFmt.SetLabelFollowedBy( aTempFmt.GetLabelFollowedBy() );
3997                 aNumFmt.SetListtabPos( aTempFmt.GetListtabPos() );
3998                 aNumFmt.SetFirstLineIndent( aTempFmt.GetFirstLineIndent() );
3999                 aNumFmt.SetIndentAt( aTempFmt.GetIndentAt() );
4000             }
4001             // <--
4002 
4003 			pActNum->SetLevel( i, aNumFmt );
4004 		}
4005 		nMask <<= 1;
4006 	}
4007 
4008 	InitControls();
4009 	SetModified();
4010 	return 0;
4011 }
4012 
SetModified(sal_Bool bRepaint)4013 void SvxNumPositionTabPage::SetModified(sal_Bool bRepaint)
4014 {
4015 	bModified = sal_True;
4016 	if(bRepaint)
4017 	{
4018 		pPreviewWIN->SetLevel(nActNumLvl);
4019 		pPreviewWIN->Invalidate();
4020 	}
4021 }
4022 
SetModified(sal_Bool bRepaint)4023 void SvxNumOptionsTabPage::SetModified(sal_Bool bRepaint)
4024 {
4025 	bModified = sal_True;
4026 	if(bRepaint)
4027 	{
4028 		pPreviewWIN->SetLevel(nActNumLvl);
4029 		pPreviewWIN->Invalidate();
4030 	}
4031 }
4032 
4033 //Add CHINA001
PageCreated(SfxAllItemSet aSet)4034 void SvxNumOptionsTabPage::PageCreated(SfxAllItemSet aSet)
4035 {
4036 	SFX_ITEMSET_ARG	(&aSet,pListItem,SfxStringListItem,SID_CHAR_FMT_LIST_BOX,sal_False);
4037 	SFX_ITEMSET_ARG	(&aSet,pNumCharFmt,SfxStringItem,SID_NUM_CHAR_FMT,sal_False);
4038 	SFX_ITEMSET_ARG	(&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,sal_False);
4039 	SFX_ITEMSET_ARG	(&aSet,pMetricItem,SfxAllEnumItem,SID_METRIC_ITEM,sal_False);
4040 
4041 	if (pNumCharFmt &&pBulletCharFmt)
4042 		SetCharFmts( pNumCharFmt->GetValue(),pBulletCharFmt->GetValue());
4043 
4044 	if (pListItem)
4045 	{
4046 		ListBox& myCharFmtLB = GetCharFmtListBox();
4047 		const List *pList = (pListItem)->GetList();
4048 		sal_uInt32 nCount = pList->Count();;
4049         for(sal_uInt32 i = 0; i < nCount; i++)
4050 		{
4051 			myCharFmtLB.InsertEntry(*(const String*)(pList->GetObject(i)) );
4052 
4053 		}
4054 	}
4055 	if (pMetricItem)
4056 		SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
4057 }
4058 
4059 //end of add CHINA001
4060 
4061 //add CHINA001 begin
4062 
PageCreated(SfxAllItemSet aSet)4063 void SvxNumPositionTabPage::PageCreated(SfxAllItemSet aSet)
4064 {
4065 	SFX_ITEMSET_ARG	(&aSet,pMetricItem,SfxAllEnumItem,SID_METRIC_ITEM,sal_False);
4066 
4067 	if (pMetricItem)
4068 		SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
4069 }
4070