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