bump product version to 4.1.6.2
[LibreOffice.git] / cui / source / tabpages / numpages.cxx
blob5bd09ae8499a67439e449ceecafe947028a1bf18
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/text/HoriOrientation.hpp>
21 #include <com/sun/star/text/VertOrientation.hpp>
22 #include <com/sun/star/text/RelOrientation.hpp>
24 #include <numpages.hxx>
25 #include <numpages.hrc>
26 #include <dialmgr.hxx>
27 #include <tools/shl.hxx>
28 #include <i18nlangtag/mslangid.hxx>
29 #include <helpid.hrc>
30 #include <editeng/numitem.hxx>
31 #include <svl/eitem.hxx>
32 #include <vcl/layout.hxx>
33 #include <vcl/svapp.hxx>
34 #include <svx/gallery.hxx>
35 #include <svl/urihelper.hxx>
36 #include <editeng/brushitem.hxx>
37 #include <svl/intitem.hxx>
38 #include <sfx2/objsh.hxx>
39 #include <vcl/graph.hxx>
40 #include <vcl/msgbox.hxx>
41 #include "cuicharmap.hxx"
42 #include <editeng/flstitem.hxx>
43 #include <svx/dlgutil.hxx>
44 #include <svx/xtable.hxx>
45 #include <svx/drawitem.hxx>
46 #include <svx/numvset.hxx>
47 #include <sfx2/htmlmode.hxx>
48 #include <unotools/pathoptions.hxx>
49 #include <svtools/ctrltool.hxx>
50 #include <editeng/unolingu.hxx>
51 #include <com/sun/star/style/NumberingType.hpp>
52 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 #include <com/sun/star/container/XIndexAccess.hpp>
54 #include <com/sun/star/text/DefaultNumberingProvider.hpp>
55 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
56 #include <com/sun/star/text/XNumberingFormatter.hpp>
57 #include <com/sun/star/beans/PropertyValue.hpp>
58 #include <comphelper/processfactory.hxx>
59 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
60 #include <svx/dialmgr.hxx>
61 #include <svx/dialogs.hrc>
62 #include <comphelper/componentcontext.hxx>
64 #include <algorithm>
65 #include <vector>
66 #include "sfx2/opengrf.hxx"
68 #include <cuires.hrc>
69 #include <sfx2/request.hxx>
70 #include <svl/aeitem.hxx>
71 #include <svl/stritem.hxx>
72 #include <svl/slstitm.hxx>
74 using namespace com::sun::star;
75 using namespace com::sun::star::uno;
76 using namespace com::sun::star::beans;
77 using namespace com::sun::star::lang;
78 using namespace com::sun::star::i18n;
79 using namespace com::sun::star::text;
80 using namespace com::sun::star::container;
81 using namespace com::sun::star::style;
83 #define NUM_PAGETYPE_BULLET 0
84 #define NUM_PAGETYPE_SINGLENUM 1
85 #define NUM_PAGETYPE_NUM 2
87 #define SHOW_NUMBERING 0
88 #define SHOW_BULLET 1
89 #define SHOW_BITMAP 2
91 #define MAX_BMP_WIDTH 16
92 #define MAX_BMP_HEIGHT 16
94 static sal_Bool bLastRelative = sal_False;
95 static const sal_Char cNumberingType[] = "NumberingType";
96 static const sal_Char cParentNumbering[] = "ParentNumbering";
97 static const sal_Char cPrefix[] = "Prefix";
98 static const sal_Char cSuffix[] = "Suffix";
99 static const sal_Char cBulletChar[] = "BulletChar";
100 static const sal_Char cBulletFontName[] = "BulletFontName";
102 static Reference<XDefaultNumberingProvider> lcl_GetNumberingProvider()
104 Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
105 Reference<XDefaultNumberingProvider> xRet = text::DefaultNumberingProvider::create(xContext);
106 return xRet;
109 static SvxNumSettings_Impl* lcl_CreateNumSettingsPtr(const Sequence<PropertyValue>& rLevelProps)
111 const PropertyValue* pValues = rLevelProps.getConstArray();
112 SvxNumSettings_Impl* pNew = new SvxNumSettings_Impl;
113 for(sal_Int32 j = 0; j < rLevelProps.getLength(); j++)
115 if ( pValues[j].Name == cNumberingType )
116 pValues[j].Value >>= pNew->nNumberType;
117 else if ( pValues[j].Name == cPrefix )
118 pValues[j].Value >>= pNew->sPrefix;
119 else if ( pValues[j].Name == cSuffix )
120 pValues[j].Value >>= pNew->sSuffix;
121 else if ( pValues[j].Name == cParentNumbering )
122 pValues[j].Value >>= pNew->nParentNumbering;
123 else if ( pValues[j].Name == cBulletChar )
124 pValues[j].Value >>= pNew->sBulletChar;
125 else if ( pValues[j].Name == cBulletFontName )
126 pValues[j].Value >>= pNew->sBulletFont;
128 return pNew;
131 // the selection of bullets from the StarSymbol
132 static const sal_Unicode aBulletTypes[] =
134 0x2022,
135 0x25cf,
136 0xe00c,
137 0xe00a,
138 0x2794,
139 0x27a2,
140 0x2717,
141 0x2714
144 static sal_Char const aNumChar[] =
146 'A', //CHARS_UPPER_LETTER
147 'a', //CHARS_LOWER_LETTER
148 'I', //ROMAN_UPPER
149 'i', //ROMAN_LOWER
150 '1', //ARABIC
154 // Is one of the masked formats set?
155 static sal_Bool lcl_IsNumFmtSet(SvxNumRule* pNum, sal_uInt16 nLevelMask)
157 sal_Bool bRet = sal_False;
158 sal_uInt16 nMask = 1;
159 for( sal_uInt16 i = 0; i < SVX_MAX_NUM && !bRet; i++ )
161 if(nLevelMask & nMask)
162 bRet |= 0 != pNum->Get( i );
163 nMask <<= 1 ;
165 return bRet;
168 static Font& lcl_GetDefaultBulletFont()
170 static sal_Bool bInit = 0;
171 static Font aDefBulletFont( OUString("StarSymbol"),
172 String(), Size( 0, 14 ) );
173 if(!bInit)
175 aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
176 aDefBulletFont.SetFamily( FAMILY_DONTKNOW );
177 aDefBulletFont.SetPitch( PITCH_DONTKNOW );
178 aDefBulletFont.SetWeight( WEIGHT_DONTKNOW );
179 aDefBulletFont.SetTransparent( sal_True );
180 bInit = sal_True;
182 return aDefBulletFont;
185 SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(Window* pParent,
186 const SfxItemSet& rSet)
187 : SfxTabPage(pParent, "PickNumberingPage", "cui/ui/picknumberingpage.ui", rSet)
188 , pActNum(0)
189 , pSaveNum(0)
190 , nActNumLvl(USHRT_MAX)
191 , bModified(false)
192 , bPreset(false)
193 , nNumItemId(SID_ATTR_NUMBERING_RULE)
195 SetExchangeSupport();
196 get(m_pExamplesVS, "valueset");
197 m_pExamplesVS->init(NUM_PAGETYPE_SINGLENUM);
198 m_pExamplesVS->SetSelectHdl(LINK(this, SvxSingleNumPickTabPage, NumSelectHdl_Impl));
199 m_pExamplesVS->SetDoubleClickHdl(LINK(this, SvxSingleNumPickTabPage, DoubleClickHdl_Impl));
201 Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
202 if(xDefNum.is())
204 Sequence< Sequence< PropertyValue > > aNumberings;
205 const Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale();
208 aNumberings =
209 xDefNum->getDefaultContinuousNumberingLevels( rLocale );
212 sal_Int32 nLength = aNumberings.getLength() > NUM_VALUSET_COUNT ? NUM_VALUSET_COUNT :aNumberings.getLength();
214 const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray();
215 for(sal_Int32 i = 0; i < nLength; i++)
217 SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(pValuesArr[i]);
218 aNumSettingsArr.push_back(pNew);
221 catch(const Exception&)
224 Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
225 m_pExamplesVS->SetNumberingSettings(aNumberings, xFormat, rLocale);
229 SvxSingleNumPickTabPage::~SvxSingleNumPickTabPage()
231 delete pActNum;
232 delete pSaveNum;
235 SfxTabPage* SvxSingleNumPickTabPage::Create( Window* pParent,
236 const SfxItemSet& rAttrSet)
238 return new SvxSingleNumPickTabPage(pParent, rAttrSet);
241 sal_Bool SvxSingleNumPickTabPage::FillItemSet( SfxItemSet& rSet )
243 if( (bPreset || bModified) && pSaveNum)
245 *pSaveNum = *pActNum;
246 rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
247 rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
250 return bModified;
253 void SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
255 const SfxPoolItem* pItem;
256 bPreset = sal_False;
257 sal_Bool bIsPreset = sal_False;
258 const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
259 if(pExampleSet)
261 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
262 bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
263 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
264 nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
266 if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
268 delete pSaveNum;
269 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
271 if(*pSaveNum != *pActNum)
273 *pActNum = *pSaveNum;
274 m_pExamplesVS->SetNoSelection();
277 if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
279 m_pExamplesVS->SelectItem(1);
280 NumSelectHdl_Impl(m_pExamplesVS);
281 bPreset = sal_True;
283 bPreset |= bIsPreset;
285 bModified = sal_False;
288 int SvxSingleNumPickTabPage::DeactivatePage(SfxItemSet *_pSet)
290 if(_pSet)
291 FillItemSet(*_pSet);
292 return sal_True;
295 void SvxSingleNumPickTabPage::Reset( const SfxItemSet& rSet )
297 const SfxPoolItem* pItem;
299 // in Draw the item exists as WhichId, in Writer only as SlotId
300 SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
301 if(eState != SFX_ITEM_SET)
303 nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
304 eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
306 if( eState != SFX_ITEM_SET )
308 pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
309 eState = SFX_ITEM_SET;
312 DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
313 delete pSaveNum;
314 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
316 if(!pActNum)
317 pActNum = new SvxNumRule(*pSaveNum);
318 else if(*pSaveNum != *pActNum)
319 *pActNum = *pSaveNum;
322 IMPL_LINK_NOARG(SvxSingleNumPickTabPage, NumSelectHdl_Impl)
324 if(pActNum)
326 bPreset = sal_False;
327 bModified = sal_True;
328 sal_uInt16 nIdx = m_pExamplesVS->GetSelectItemId() - 1;
329 DBG_ASSERT(aNumSettingsArr.size() > nIdx, "wrong index");
330 if(aNumSettingsArr.size() <= nIdx)
331 return 0;
332 SvxNumSettings_Impl* _pSet = &aNumSettingsArr[nIdx];
333 sal_Int16 eNewType = _pSet->nNumberType;
334 const sal_Unicode cLocalPrefix = !_pSet->sPrefix.isEmpty() ? _pSet->sPrefix.getStr()[0] : 0;
335 const sal_Unicode cLocalSuffix = !_pSet->sSuffix.isEmpty() ? _pSet->sSuffix.getStr()[0] : 0;
337 sal_uInt16 nMask = 1;
338 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
340 if(nActNumLvl & nMask)
342 SvxNumberFormat aFmt(pActNum->GetLevel(i));
343 aFmt.SetNumberingType(eNewType);
344 String aEmptyStr;
345 if(cLocalPrefix == ' ')
346 aFmt.SetPrefix( aEmptyStr );
347 else
348 aFmt.SetPrefix(_pSet->sPrefix);
349 if(cLocalSuffix == ' ')
350 aFmt.SetSuffix( aEmptyStr );
351 else
352 aFmt.SetSuffix(_pSet->sSuffix);
353 aFmt.SetCharFmtName(sNumCharFmtName);
354 // #62069# // #92724#
355 aFmt.SetBulletRelSize(100);
356 pActNum->SetLevel(i, aFmt);
358 nMask <<= 1 ;
361 return 0;
364 IMPL_LINK_NOARG(SvxSingleNumPickTabPage, DoubleClickHdl_Impl)
366 NumSelectHdl_Impl(m_pExamplesVS);
367 OKButton& rOk = GetTabDialog()->GetOKButton();
368 rOk.GetClickHdl().Call(&rOk);
369 return 0;
373 SvxBulletPickTabPage::SvxBulletPickTabPage(Window* pParent,
374 const SfxItemSet& rSet)
375 : SfxTabPage(pParent, "PickBulletPage", "cui/ui/pickbulletpage.ui", rSet)
376 , pActNum(0)
377 , pSaveNum(0)
378 , nActNumLvl(USHRT_MAX)
379 , bModified(false)
380 , bPreset(false)
381 , nNumItemId(SID_ATTR_NUMBERING_RULE)
383 SetExchangeSupport();
384 get(m_pExamplesVS, "valueset");
385 m_pExamplesVS->init(NUM_PAGETYPE_BULLET),
386 m_pExamplesVS->SetSelectHdl(LINK(this, SvxBulletPickTabPage, NumSelectHdl_Impl));
387 m_pExamplesVS->SetDoubleClickHdl(LINK(this, SvxBulletPickTabPage, DoubleClickHdl_Impl));
390 SvxBulletPickTabPage::~SvxBulletPickTabPage()
392 delete pActNum;
393 delete pSaveNum;
396 SfxTabPage* SvxBulletPickTabPage::Create( Window* pParent,
397 const SfxItemSet& rAttrSet)
399 return new SvxBulletPickTabPage(pParent, rAttrSet);
402 sal_Bool SvxBulletPickTabPage::FillItemSet( SfxItemSet& rSet )
404 if( (bPreset || bModified) && pActNum)
406 *pSaveNum = *pActNum;
407 rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
408 rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
410 return bModified;
413 void SvxBulletPickTabPage::ActivatePage(const SfxItemSet& rSet)
415 const SfxPoolItem* pItem;
416 bPreset = sal_False;
417 sal_Bool bIsPreset = sal_False;
418 const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
419 if(pExampleSet)
421 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
422 bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
423 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
424 nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
426 if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
428 delete pSaveNum;
429 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
431 if(*pSaveNum != *pActNum)
433 *pActNum = *pSaveNum;
434 m_pExamplesVS->SetNoSelection();
437 if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
439 m_pExamplesVS->SelectItem(1);
440 NumSelectHdl_Impl(m_pExamplesVS);
441 bPreset = sal_True;
443 bPreset |= bIsPreset;
444 bModified = sal_False;
447 int SvxBulletPickTabPage::DeactivatePage(SfxItemSet *_pSet)
449 if(_pSet)
450 FillItemSet(*_pSet);
451 return sal_True;
454 void SvxBulletPickTabPage::Reset( const SfxItemSet& rSet )
456 const SfxPoolItem* pItem;
457 // in Draw the item exists as WhichId, in Writer only as SlotId
458 SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
459 if(eState != SFX_ITEM_SET)
461 nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
462 eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
464 if( eState != SFX_ITEM_SET )
466 pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
467 eState = SFX_ITEM_SET;
471 DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
472 delete pSaveNum;
473 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
475 if(!pActNum)
476 pActNum = new SvxNumRule(*pSaveNum);
477 else if(*pSaveNum != *pActNum)
478 *pActNum = *pSaveNum;
481 IMPL_LINK_NOARG(SvxBulletPickTabPage, NumSelectHdl_Impl)
483 if(pActNum)
485 bPreset = sal_False;
486 bModified = sal_True;
487 sal_Unicode cChar = aBulletTypes[m_pExamplesVS->GetSelectItemId() - 1];
488 Font& rActBulletFont = lcl_GetDefaultBulletFont();
490 sal_uInt16 nMask = 1;
491 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
493 if(nActNumLvl & nMask)
495 SvxNumberFormat aFmt(pActNum->GetLevel(i));
496 aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
497 // #i93908# clear suffix for bullet lists
498 aFmt.SetPrefix( OUString() );
499 aFmt.SetSuffix( OUString() );
500 aFmt.SetBulletFont(&rActBulletFont);
501 aFmt.SetBulletChar(cChar );
502 aFmt.SetCharFmtName(sBulletCharFmtName);
503 // #62069# // #92724#
504 aFmt.SetBulletRelSize(45);
505 pActNum->SetLevel(i, aFmt);
507 nMask <<= 1;
511 return 0;
515 IMPL_LINK_NOARG(SvxBulletPickTabPage, DoubleClickHdl_Impl)
517 NumSelectHdl_Impl(m_pExamplesVS);
518 OKButton& rOk = GetTabDialog()->GetOKButton();
519 rOk.GetClickHdl().Call(&rOk);
520 return 0;
524 void SvxBulletPickTabPage::PageCreated(SfxAllItemSet aSet)
527 SFX_ITEMSET_ARG (&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,sal_False);
529 if (pBulletCharFmt)
530 SetCharFmtName( pBulletCharFmt->GetValue());
536 SvxNumPickTabPage::SvxNumPickTabPage(Window* pParent,
537 const SfxItemSet& rSet)
538 : SfxTabPage(pParent, "PickOutlinePage", "cui/ui/pickoutlinepage.ui", rSet)
539 , pActNum(0)
540 , pSaveNum(0)
541 , nActNumLvl(USHRT_MAX)
542 , nNumItemId(SID_ATTR_NUMBERING_RULE)
543 , bModified(false)
544 , bPreset(false)
546 SetExchangeSupport();
548 get(m_pExamplesVS, "valueset");
549 m_pExamplesVS->init(NUM_PAGETYPE_NUM);
550 m_pExamplesVS->SetSelectHdl(LINK(this, SvxNumPickTabPage, NumSelectHdl_Impl));
551 m_pExamplesVS->SetDoubleClickHdl(LINK(this, SvxNumPickTabPage, DoubleClickHdl_Impl));
553 Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
554 if(xDefNum.is())
556 Sequence<Reference<XIndexAccess> > aOutlineAccess;
557 const Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale();
560 aOutlineAccess = xDefNum->getDefaultOutlineNumberings( rLocale );
562 for(sal_Int32 nItem = 0;
563 nItem < aOutlineAccess.getLength() && nItem < NUM_VALUSET_COUNT;
564 nItem++ )
566 SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[ nItem ];
568 Reference<XIndexAccess> xLevel = aOutlineAccess.getConstArray()[nItem];
569 for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++)
571 Any aValueAny = xLevel->getByIndex(nLevel);
572 Sequence<PropertyValue> aLevelProps;
573 aValueAny >>= aLevelProps;
574 SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(aLevelProps);
575 rItemArr.push_back( pNew );
579 catch(const Exception&)
582 Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
583 m_pExamplesVS->SetOutlineNumberingSettings(aOutlineAccess, xFormat, rLocale);
587 SvxNumPickTabPage::~SvxNumPickTabPage()
589 delete pActNum;
590 delete pSaveNum;
593 SfxTabPage* SvxNumPickTabPage::Create( Window* pParent,
594 const SfxItemSet& rAttrSet)
596 return new SvxNumPickTabPage(pParent, rAttrSet);
599 sal_Bool SvxNumPickTabPage::FillItemSet( SfxItemSet& rSet )
601 if( (bPreset || bModified) && pActNum)
603 *pSaveNum = *pActNum;
604 rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
605 rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
607 return bModified;
610 void SvxNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
612 const SfxPoolItem* pItem;
613 bPreset = sal_False;
614 sal_Bool bIsPreset = sal_False;
615 const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
616 if(pExampleSet)
618 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
619 bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
620 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
621 nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
623 if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
625 delete pSaveNum;
626 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
628 if(*pSaveNum != *pActNum)
630 *pActNum = *pSaveNum;
631 m_pExamplesVS->SetNoSelection();
634 if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
636 m_pExamplesVS->SelectItem(1);
637 NumSelectHdl_Impl(m_pExamplesVS);
638 bPreset = sal_True;
640 bPreset |= bIsPreset;
641 bModified = sal_False;
644 int SvxNumPickTabPage::DeactivatePage(SfxItemSet *_pSet)
646 if(_pSet)
647 FillItemSet(*_pSet);
648 return sal_True;
651 void SvxNumPickTabPage::Reset( const SfxItemSet& rSet )
653 const SfxPoolItem* pItem;
654 // in Draw the item exists as WhichId, in Writer only as SlotId
655 SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
656 if(eState != SFX_ITEM_SET)
658 nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
659 eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
661 if( eState != SFX_ITEM_SET )
663 pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
664 eState = SFX_ITEM_SET;
668 DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
669 delete pSaveNum;
670 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
672 if(!pActNum)
673 pActNum = new SvxNumRule(*pSaveNum);
674 else if(*pSaveNum != *pActNum)
675 *pActNum = *pSaveNum;
679 // all levels are changed here
680 IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl)
682 if(pActNum)
684 bPreset = sal_False;
685 bModified = sal_True;
687 const FontList* pList = 0;
689 SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[m_pExamplesVS->GetSelectItemId() - 1];
691 Font& rActBulletFont = lcl_GetDefaultBulletFont();
692 SvxNumSettings_Impl* pLevelSettings = 0;
693 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
695 if(rItemArr.size() > i)
696 pLevelSettings = &rItemArr[i];
697 if(!pLevelSettings)
698 break;
699 SvxNumberFormat aFmt(pActNum->GetLevel(i));
700 aFmt.SetNumberingType( pLevelSettings->nNumberType );
701 sal_uInt16 nUpperLevelOrChar = (sal_uInt16)pLevelSettings->nParentNumbering;
702 if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL)
704 // #i93908# clear suffix for bullet lists
705 aFmt.SetPrefix(OUString());
706 aFmt.SetSuffix(OUString());
707 if( !pLevelSettings->sBulletFont.isEmpty() &&
708 pLevelSettings->sBulletFont.compareTo(
709 rActBulletFont.GetName()))
711 //search for the font
712 if(!pList)
714 SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
715 const SvxFontListItem* pFontListItem =
716 (const SvxFontListItem* )pCurDocShell
717 ->GetItem( SID_ATTR_CHAR_FONTLIST );
718 pList = pFontListItem ? pFontListItem->GetFontList() : 0;
720 if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) )
722 FontInfo aInfo = pList->Get(
723 pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE);
724 Font aFont(aInfo);
725 aFmt.SetBulletFont(&aFont);
727 else
729 //if it cannot be found then create a new one
730 Font aCreateFont( pLevelSettings->sBulletFont,
731 String(), Size( 0, 14 ) );
732 aCreateFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW );
733 aCreateFont.SetFamily( FAMILY_DONTKNOW );
734 aCreateFont.SetPitch( PITCH_DONTKNOW );
735 aCreateFont.SetWeight( WEIGHT_DONTKNOW );
736 aCreateFont.SetTransparent( sal_True );
737 aFmt.SetBulletFont( &aCreateFont );
740 else
741 aFmt.SetBulletFont( &rActBulletFont );
743 aFmt.SetBulletChar( !pLevelSettings->sBulletChar.isEmpty()
744 ? pLevelSettings->sBulletChar.getStr()[0]
745 : 0 );
746 aFmt.SetCharFmtName( sBulletCharFmtName );
747 // #62069# // #92724#
748 aFmt.SetBulletRelSize(45);
750 else
752 aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? pActNum->GetLevelCount() : 0));
753 aFmt.SetCharFmtName(sNumCharFmtName);
754 // #62069# // #92724#
755 aFmt.SetBulletRelSize(100);
756 // #i93908#
757 aFmt.SetPrefix(pLevelSettings->sPrefix);
758 aFmt.SetSuffix(pLevelSettings->sSuffix);
760 pActNum->SetLevel(i, aFmt);
763 return 0;
766 IMPL_LINK_NOARG(SvxNumPickTabPage, DoubleClickHdl_Impl)
768 NumSelectHdl_Impl(m_pExamplesVS);
769 OKButton& rOk = GetTabDialog()->GetOKButton();
770 rOk.GetClickHdl().Call(&rOk);
771 return 0;
774 void SvxNumPickTabPage::PageCreated(SfxAllItemSet aSet)
776 SFX_ITEMSET_ARG (&aSet,pNumCharFmt,SfxStringItem,SID_NUM_CHAR_FMT,sal_False);
777 SFX_ITEMSET_ARG (&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,sal_False);
780 if (pNumCharFmt &&pBulletCharFmt)
781 SetCharFmtNames( pNumCharFmt->GetValue(),pBulletCharFmt->GetValue());
784 SvxBitmapPickTabPage::SvxBitmapPickTabPage(Window* pParent,
785 const SfxItemSet& rSet)
786 : SfxTabPage(pParent, "PickGraphicPage", "cui/ui/pickgraphicpage.ui", rSet)
787 , pActNum(0)
788 , pSaveNum(0)
789 , nActNumLvl(USHRT_MAX)
790 , nNumItemId(SID_ATTR_NUMBERING_RULE)
791 , bModified(false)
792 , bPreset(false)
794 SetExchangeSupport();
795 get(m_pErrorText, "errorft");
796 get(m_pLinkedCB, "linkgraphics");
797 get(m_pExamplesVS, "valueset");
798 m_pExamplesVS->SetSelectHdl(LINK(this, SvxBitmapPickTabPage, NumSelectHdl_Impl));
799 m_pExamplesVS->SetDoubleClickHdl(LINK(this, SvxBitmapPickTabPage, DoubleClickHdl_Impl));
800 m_pLinkedCB->SetClickHdl(LINK(this, SvxBitmapPickTabPage, LinkBmpHdl_Impl));
802 eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
804 // determine graphic name
805 GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames);
807 sal_uInt16 i = 0;
808 for(std::vector<String>::iterator it = aGrfNames.begin(); it != aGrfNames.end(); ++it, ++i)
810 m_pExamplesVS->InsertItem( i + 1, i);
812 INetURLObject aObj(*it);
813 if(aObj.GetProtocol() == INET_PROT_FILE)
814 *it = aObj.PathToFileName();
816 m_pExamplesVS->SetItemText( i + 1, *it );
819 if(aGrfNames.empty())
821 m_pErrorText->Show();
823 else
825 m_pExamplesVS->Show();
826 m_pExamplesVS->Format();
830 SvxBitmapPickTabPage::~SvxBitmapPickTabPage()
832 delete pActNum;
833 delete pSaveNum;
836 SfxTabPage* SvxBitmapPickTabPage::Create( Window* pParent,
837 const SfxItemSet& rAttrSet)
839 return new SvxBitmapPickTabPage(pParent, rAttrSet);
842 void SvxBitmapPickTabPage::ActivatePage(const SfxItemSet& rSet)
844 const SfxPoolItem* pItem;
845 bPreset = sal_False;
846 sal_Bool bIsPreset = sal_False;
847 const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
848 if(pExampleSet)
850 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
851 bIsPreset = ((const SfxBoolItem*)pItem)->GetValue();
852 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
853 nActNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
855 if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
857 delete pSaveNum;
858 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
860 if(*pSaveNum != *pActNum)
862 *pActNum = *pSaveNum;
863 m_pExamplesVS->SetNoSelection();
866 if(!aGrfNames.empty() &&
867 (pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset)))
869 m_pExamplesVS->SelectItem(1);
870 NumSelectHdl_Impl(m_pExamplesVS);
871 bPreset = sal_True;
873 bPreset |= bIsPreset;
874 bModified = sal_False;
877 int SvxBitmapPickTabPage::DeactivatePage(SfxItemSet *_pSet)
879 if(_pSet)
880 FillItemSet(*_pSet);
881 return sal_True;
884 sal_Bool SvxBitmapPickTabPage::FillItemSet( SfxItemSet& rSet )
886 if ( aGrfNames.empty() )
888 return sal_False;
890 if( (bPreset || bModified) && pActNum)
892 *pSaveNum = *pActNum;
893 rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
894 rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
897 return bModified;
900 void SvxBitmapPickTabPage::Reset( const SfxItemSet& rSet )
902 const SfxPoolItem* pItem;
903 // in Draw the item exists as WhichId, in Writer only as SlotId
904 SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
905 if(eState != SFX_ITEM_SET)
907 nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
908 eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
910 if( eState != SFX_ITEM_SET )
912 pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
913 eState = SFX_ITEM_SET;
917 DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
918 delete pSaveNum;
919 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
921 if(!pActNum)
922 pActNum = new SvxNumRule(*pSaveNum);
923 else if(*pSaveNum != *pActNum)
924 *pActNum = *pSaveNum;
925 if(!pActNum->IsFeatureSupported(NUM_ENABLE_LINKED_BMP))
927 m_pLinkedCB->Check(sal_False);
928 m_pLinkedCB->Enable(sal_False);
930 else if(!pActNum->IsFeatureSupported(NUM_ENABLE_EMBEDDED_BMP))
932 m_pLinkedCB->Check(sal_True);
933 m_pLinkedCB->Enable(sal_False);
937 IMPL_LINK_NOARG(SvxBitmapPickTabPage, NumSelectHdl_Impl)
939 if(pActNum)
941 bPreset = sal_False;
942 bModified = sal_True;
943 sal_uInt16 nIdx = m_pExamplesVS->GetSelectItemId() - 1;
945 sal_uInt16 nMask = 1;
946 String aEmptyStr;
947 sal_uInt16 nSetNumberingType = SVX_NUM_BITMAP;
948 if(m_pLinkedCB->IsChecked())
949 nSetNumberingType |= LINK_TOKEN;
950 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
952 if(nActNumLvl & nMask)
954 SvxNumberFormat aFmt(pActNum->GetLevel(i));
955 aFmt.SetNumberingType(nSetNumberingType);
956 aFmt.SetPrefix( aEmptyStr );
957 aFmt.SetSuffix( aEmptyStr );
958 aFmt.SetCharFmtName( sNumCharFmtName );
960 Graphic aGraphic;
961 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nIdx, &aGraphic))
963 Size aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
964 sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
965 aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)eCoreUnit);
966 SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH );
967 aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
969 else if(aGrfNames.size() > nIdx)
970 aFmt.SetGraphic( aGrfNames[nIdx] );
971 pActNum->SetLevel(i, aFmt);
973 nMask <<= 1 ;
977 return 0;
980 IMPL_LINK_NOARG(SvxBitmapPickTabPage, DoubleClickHdl_Impl)
982 NumSelectHdl_Impl(m_pExamplesVS);
983 OKButton& rOk = GetTabDialog()->GetOKButton();
984 rOk.GetClickHdl().Call(&rOk);
985 return 0;
988 IMPL_LINK_NOARG(SvxBitmapPickTabPage, LinkBmpHdl_Impl)
990 if(!m_pExamplesVS->IsNoSelection())
992 NumSelectHdl_Impl(m_pExamplesVS);
994 return 0;
997 // static
998 void SvxNumOptionsTabPage::GetI18nNumbering( ListBox& rFmtLB, sal_uInt16 nDoNotRemove )
1001 Reference<XDefaultNumberingProvider> xDefNum = lcl_GetNumberingProvider();
1002 Reference<XNumberingTypeInfo> xInfo(xDefNum, UNO_QUERY);
1004 // Extended numbering schemes present in the resource but not offered by
1005 // the i18n framework per configuration must be removed from the listbox.
1006 // Do not remove a special entry matching nDoNotRemove.
1007 const sal_uInt16 nDontRemove = 0xffff;
1008 ::std::vector< sal_uInt16> aRemove( rFmtLB.GetEntryCount(), nDontRemove);
1009 for (size_t i=0; i<aRemove.size(); ++i)
1011 sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)rFmtLB.GetEntryData(
1012 sal::static_int_cast< sal_uInt16 >(i));
1013 if (nEntryData > NumberingType::CHARS_LOWER_LETTER_N && nEntryData != nDoNotRemove)
1014 aRemove[i] = nEntryData;
1016 if(xInfo.is())
1018 Sequence<sal_Int16> aTypes = xInfo->getSupportedNumberingTypes( );
1019 const sal_Int16* pTypes = aTypes.getConstArray();
1020 for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
1022 sal_Int16 nCurrent = pTypes[nType];
1023 if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N)
1025 sal_Bool bInsert = sal_True;
1026 for(sal_uInt16 nEntry = 0; nEntry < rFmtLB.GetEntryCount(); nEntry++)
1028 sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)rFmtLB.GetEntryData(nEntry);
1029 if(nEntryData == (sal_uInt16) nCurrent)
1031 bInsert = sal_False;
1032 aRemove[nEntry] = nDontRemove;
1033 break;
1036 if(bInsert)
1038 OUString aIdent = xInfo->getNumberingIdentifier( nCurrent );
1039 sal_uInt16 nPos = rFmtLB.InsertEntry(aIdent);
1040 rFmtLB.SetEntryData(nPos,(void*)(sal_uLong)nCurrent);
1045 for (size_t i=0; i<aRemove.size(); ++i)
1047 if (aRemove[i] != nDontRemove)
1049 sal_uInt16 nPos = rFmtLB.GetEntryPos( (void*)(sal_uLong)aRemove[i]);
1050 rFmtLB.RemoveEntry( nPos);
1055 // tabpage numbering options
1056 SvxNumOptionsTabPage::SvxNumOptionsTabPage(Window* pParent,
1057 const SfxItemSet& rSet)
1058 : SfxTabPage(pParent, "NumberingOptionsPage", "cui/ui/numberingoptionspage.ui", rSet)
1059 , pActNum(0)
1060 , pSaveNum(0)
1061 , bLastWidthModified(sal_False)
1062 , bModified(sal_False)
1063 , bPreset(sal_False)
1064 , bAutomaticCharStyles(sal_True)
1065 , bHTMLMode(sal_False)
1066 , bMenuButtonInitialized(sal_False)
1067 , nBullet(0xff)
1068 , nActNumLvl(USHRT_MAX)
1069 , nNumItemId(SID_ATTR_NUMBERING_RULE)
1071 get(m_pLevelLB, "levellb");
1072 get(m_pFmtLB, "numfmtlb");
1074 get(m_pSeparatorFT, "separator");
1075 get(m_pPrefixFT, "prefixft");
1076 get(m_pPrefixED, "prefix");
1077 get(m_pSuffixFT, "suffixft");
1078 get(m_pSuffixED, "suffix");
1080 get(m_pCharFmtFT, "charstyleft");
1081 get(m_pCharFmtLB, "charstyle");
1083 get(m_pBulColorFT, "colorft");
1084 get(m_pBulColLB, "color");
1086 get(m_pBulRelSizeFT, "relsizeft");
1087 get(m_pBulRelSizeMF, "relsize");
1089 get(m_pAllLevelFT, "sublevelsft");
1090 get(m_pAllLevelNF, "sublevels");
1092 get(m_pStartFT, "startatft");
1093 get(m_pStartED, "startat");
1095 get(m_pBulletFT, "bulletft");
1096 get(m_pBulletPB, "bullet");
1098 get(m_pAlignFT, "numalignft");
1099 get(m_pAlignLB, "numalign");
1101 get(m_pBitmapFT, "bitmapft");
1102 get(m_pBitmapMB, "bitmap");
1104 get(m_pWidthFT, "widthft");
1105 get(m_pWidthMF, "widthmf");
1106 get(m_pHeightFT, "heightft");
1107 get(m_pHeightMF, "heightmf");
1109 get(m_pRatioCB, "keepratio");
1111 get(m_pOrientFT, "orientft");
1112 get(m_pOrientLB, "orientlb");
1114 get(m_pAllLevelsFrame, "levelsframe");
1115 get(m_pSameLevelCB, "allsame");
1117 get(m_pPreviewWIN, "preview");
1119 m_pPreviewWIN->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
1120 SetExchangeSupport();
1121 aActBulletFont = lcl_GetDefaultBulletFont();
1123 m_pBulletPB->SetClickHdl(LINK(this, SvxNumOptionsTabPage, BulletHdl_Impl));
1124 m_pFmtLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl));
1125 m_pBitmapMB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, GraphicHdl_Impl));
1126 m_pLevelLB->EnableMultiSelection(true);
1127 m_pLevelLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, LevelHdl_Impl));
1128 m_pCharFmtLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, CharFmtHdl_Impl));
1129 m_pWidthMF->SetModifyHdl(LINK(this, SvxNumOptionsTabPage, SizeHdl_Impl));
1130 m_pHeightMF->SetModifyHdl(LINK(this, SvxNumOptionsTabPage, SizeHdl_Impl));
1131 m_pRatioCB->SetClickHdl(LINK(this, SvxNumOptionsTabPage, RatioHdl_Impl));
1132 m_pStartED->SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1133 m_pPrefixED->SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1134 m_pSuffixED->SetModifyHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1135 m_pAllLevelNF->SetModifyHdl(LINK(this,SvxNumOptionsTabPage, AllLevelHdl_Impl));
1136 m_pOrientLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, OrientHdl_Impl));
1137 m_pSameLevelCB->SetClickHdl(LINK(this, SvxNumOptionsTabPage, SameLevelHdl_Impl));
1138 m_pBulRelSizeMF->SetModifyHdl(LINK(this,SvxNumOptionsTabPage, BulRelSizeHdl_Impl));
1139 m_pBulColLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, BulColorHdl_Impl));
1140 aInvalidateTimer.SetTimeoutHdl(LINK(this, SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl));
1141 aInvalidateTimer.SetTimeout(50);
1143 Menu *pBitmapMenu = m_pBitmapMB->GetPopupMenu();
1145 pBitmapMenu->SetHighlightHdl(LINK(this, SvxNumOptionsTabPage, PopupActivateHdl_Impl));
1146 m_nGalleryId = pBitmapMenu->GetItemId("gallery");
1147 assert(m_nGalleryId != MENU_ITEM_NOTFOUND);
1148 PopupMenu* pPopup = new PopupMenu;
1149 pBitmapMenu->SetPopupMenu(m_nGalleryId, pPopup);
1151 eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
1153 // Get advanced numbering types from the component.
1154 // Watch out for the ugly 0x88/*SVX_NUM_BITMAP|0x80*/ to not remove that.
1155 GetI18nNumbering( *m_pFmtLB, (SVX_NUM_BITMAP | 0x80));
1158 SvxNumOptionsTabPage::~SvxNumOptionsTabPage()
1160 delete m_pBitmapMB->GetPopupMenu()->GetPopupMenu(m_nGalleryId);
1161 delete pActNum;
1162 delete pSaveNum;
1165 void SvxNumOptionsTabPage::SetMetric(FieldUnit eMetric)
1167 if(eMetric == FUNIT_MM)
1169 m_pWidthMF->SetDecimalDigits(1);
1170 m_pHeightMF->SetDecimalDigits(1);
1172 m_pWidthMF->SetUnit( eMetric );
1173 m_pHeightMF->SetUnit( eMetric );
1176 SfxTabPage* SvxNumOptionsTabPage::Create( Window* pParent,
1177 const SfxItemSet& rAttrSet)
1179 return new SvxNumOptionsTabPage(pParent, rAttrSet);
1182 void SvxNumOptionsTabPage::ActivatePage(const SfxItemSet& rSet)
1184 const SfxPoolItem* pItem;
1185 const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
1186 sal_uInt16 nTmpNumLvl = USHRT_MAX;
1187 if(pExampleSet)
1189 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
1190 bPreset = ((const SfxBoolItem*)pItem)->GetValue();
1191 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
1192 nTmpNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
1194 if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
1196 delete pSaveNum;
1197 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
1200 bModified = (!pActNum->Get( 0 ) || bPreset);
1201 if(*pActNum != *pSaveNum ||
1202 nActNumLvl != nTmpNumLvl)
1204 nActNumLvl = nTmpNumLvl;
1205 sal_uInt16 nMask = 1;
1206 m_pLevelLB->SetUpdateMode(sal_False);
1207 m_pLevelLB->SetNoSelection();
1208 m_pLevelLB->SelectEntryPos( pActNum->GetLevelCount(), nActNumLvl == USHRT_MAX);
1209 if(nActNumLvl != USHRT_MAX)
1210 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1212 if(nActNumLvl & nMask)
1213 m_pLevelLB->SelectEntryPos( i, sal_True);
1214 nMask <<= 1 ;
1216 m_pLevelLB->SetUpdateMode(sal_True);
1217 *pActNum = *pSaveNum;
1218 InitControls();
1223 int SvxNumOptionsTabPage::DeactivatePage(SfxItemSet * _pSet)
1225 if(_pSet)
1226 FillItemSet(*_pSet);
1227 return sal_True;
1230 sal_Bool SvxNumOptionsTabPage::FillItemSet( SfxItemSet& rSet )
1232 rSet.Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
1233 if(bModified && pActNum)
1235 *pSaveNum = *pActNum;
1236 rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
1237 rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, sal_False));
1239 return bModified;
1242 void SvxNumOptionsTabPage::Reset( const SfxItemSet& rSet )
1244 const SfxPoolItem* pItem;
1245 // in Draw the item exists as WhichId, in Writer only as SlotId
1246 SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
1247 if(eState != SFX_ITEM_SET)
1249 nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
1250 eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
1252 if( eState != SFX_ITEM_SET )
1254 pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
1255 eState = SFX_ITEM_SET;
1259 DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
1260 delete pSaveNum;
1261 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
1263 // insert levels
1264 if(!m_pLevelLB->GetEntryCount())
1266 for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
1267 m_pLevelLB->InsertEntry( OUString::number(i));
1268 if(pSaveNum->GetLevelCount() > 1)
1270 OUString sEntry( "1 - " );
1271 sEntry += OUString::valueOf( static_cast<sal_Int32>(pSaveNum->GetLevelCount()) );
1272 m_pLevelLB->InsertEntry(sEntry);
1273 m_pLevelLB->SelectEntry(sEntry);
1275 else
1276 m_pLevelLB->SelectEntryPos(0);
1278 else
1279 m_pLevelLB->SelectEntryPos(m_pLevelLB->GetEntryCount() - 1);
1281 sal_uInt16 nMask = 1;
1282 m_pLevelLB->SetUpdateMode(sal_False);
1283 m_pLevelLB->SetNoSelection();
1284 if(nActNumLvl == USHRT_MAX)
1286 m_pLevelLB->SelectEntryPos( pSaveNum->GetLevelCount(), sal_True);
1288 else
1289 for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
1291 if(nActNumLvl & nMask)
1292 m_pLevelLB->SelectEntryPos( i, sal_True);
1293 nMask <<= 1 ;
1295 m_pLevelLB->SetUpdateMode(sal_True);
1297 if(!pActNum)
1298 pActNum = new SvxNumRule(*pSaveNum);
1299 else if(*pSaveNum != *pActNum)
1300 *pActNum = *pSaveNum;
1301 m_pPreviewWIN->SetNumRule(pActNum);
1302 m_pSameLevelCB->Check(pActNum->IsContinuousNumbering());
1304 // fill ColorListBox as needed
1305 if ( pActNum->IsFeatureSupported( NUM_BULLET_COLOR ) )
1307 SfxObjectShell* pDocSh = SfxObjectShell::Current();
1308 DBG_ASSERT( pDocSh, "DocShell not found!" );
1309 XColorListRef pColorTable;
1310 if ( pDocSh )
1312 pItem = pDocSh->GetItem( SID_COLOR_TABLE );
1313 if ( pItem )
1314 pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
1317 if ( !pColorTable.is() )
1318 pColorTable = XColorList::CreateStdColorList();
1320 m_pBulColLB->InsertEntry( Color( COL_AUTO ), SVX_RESSTR( RID_SVXSTR_AUTOMATIC ));
1322 for ( long i = 0; i < pColorTable->Count(); i++ )
1324 XColorEntry* pEntry = pColorTable->GetColor(i);
1325 m_pBulColLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
1329 SfxObjectShell* pShell;
1330 if ( SFX_ITEM_SET == rSet.GetItemState( SID_HTML_MODE, sal_False, &pItem )
1331 || ( 0 != ( pShell = SfxObjectShell::Current()) &&
1332 0 != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
1334 sal_uInt16 nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
1335 bHTMLMode = 0 != (nHtmlMode&HTMLMODE_ON);
1338 sal_Bool bCharFmt = pActNum->IsFeatureSupported(NUM_CHAR_STYLE);
1339 m_pCharFmtFT->Show(bCharFmt);
1340 m_pCharFmtLB->Show(bCharFmt);
1342 sal_Bool bContinuous = pActNum->IsFeatureSupported(NUM_CONTINUOUS);
1344 sal_Bool bAllLevel = bContinuous && !bHTMLMode;
1345 m_pAllLevelFT->Show(bAllLevel);
1346 m_pAllLevelNF->Show(bAllLevel);
1348 m_pAllLevelsFrame->Show(bContinuous);
1350 // again misusage: in Draw there is numeration only until the bitmap
1351 // without SVX_NUM_NUMBER_NONE
1352 //remove types that are unsupported by Draw/Impress
1353 if(!bContinuous)
1355 sal_uInt16 nFmtCount = m_pFmtLB->GetEntryCount();
1356 for(sal_uInt16 i = nFmtCount; i; i--)
1358 sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)m_pFmtLB->GetEntryData(i - 1);
1359 if(/*SVX_NUM_NUMBER_NONE == nEntryData ||*/
1360 ((SVX_NUM_BITMAP|LINK_TOKEN) == nEntryData))
1361 m_pFmtLB->RemoveEntry(i - 1);
1364 //one must be enabled
1365 if(!pActNum->IsFeatureSupported(NUM_ENABLE_LINKED_BMP))
1367 long nData = SVX_NUM_BITMAP|LINK_TOKEN;
1368 sal_uInt16 nPos = m_pFmtLB->GetEntryPos((void*)nData);
1369 if(LISTBOX_ENTRY_NOTFOUND != nPos)
1370 m_pFmtLB->RemoveEntry(nPos);
1372 else if(!pActNum->IsFeatureSupported(NUM_ENABLE_EMBEDDED_BMP))
1374 long nData = SVX_NUM_BITMAP;
1375 sal_uInt16 nPos = m_pFmtLB->GetEntryPos((void*)nData);
1376 if(LISTBOX_ENTRY_NOTFOUND != nPos)
1377 m_pFmtLB->RemoveEntry(nPos);
1379 if(pActNum->IsFeatureSupported(NUM_SYMBOL_ALIGNMENT))
1381 m_pAlignFT->Show();
1382 m_pAlignLB->Show();
1383 m_pAlignLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1385 else
1387 m_pAlignFT->Hide();
1388 m_pAlignLB->Hide();
1391 // MegaHack: because of a not-fixable 'design mistake/error' in Impress
1392 // delete all kinds of numeric enumerations
1393 if(pActNum->IsFeatureSupported(NUM_NO_NUMBERS))
1395 sal_uInt16 nFmtCount = m_pFmtLB->GetEntryCount();
1396 for(sal_uInt16 i = nFmtCount; i; i--)
1398 sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)m_pFmtLB->GetEntryData(i - 1);
1399 if( /*nEntryData >= SVX_NUM_CHARS_UPPER_LETTER &&*/ nEntryData <= SVX_NUM_NUMBER_NONE)
1400 m_pFmtLB->RemoveEntry(i - 1);
1404 InitControls();
1405 bModified = sal_False;
1409 void SvxNumOptionsTabPage::InitControls()
1411 sal_Bool bShowBullet = sal_True;
1412 sal_Bool bShowBitmap = sal_True;
1413 sal_Bool bSameType = sal_True;
1414 sal_Bool bSameStart = sal_True;
1415 sal_Bool bSamePrefix = sal_True;
1416 sal_Bool bSameSuffix = sal_True;
1417 sal_Bool bAllLevel = sal_True;
1418 sal_Bool bSameCharFmt = sal_True;
1419 sal_Bool bSameVOrient = sal_True;
1420 sal_Bool bSameSize = sal_True;
1421 sal_Bool bSameBulColor = sal_True;
1422 sal_Bool bSameBulRelSize= sal_True;
1423 sal_Bool bSameAdjust = sal_True;
1425 const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
1426 String sFirstCharFmt;
1427 sal_Int16 eFirstOrient = text::VertOrientation::NONE;
1428 Size aFirstSize(0,0);
1429 sal_uInt16 nMask = 1;
1430 sal_uInt16 nLvl = USHRT_MAX;
1431 sal_uInt16 nHighestLevel = 0;
1432 String aEmptyStr;
1434 sal_Bool bBullColor = pActNum->IsFeatureSupported(NUM_BULLET_COLOR);
1435 sal_Bool bBullRelSize = pActNum->IsFeatureSupported(NUM_BULLET_REL_SIZE);
1436 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1438 if(nActNumLvl & nMask)
1440 aNumFmtArr[i] = &pActNum->GetLevel(i);
1441 bShowBullet &= aNumFmtArr[i]->GetNumberingType() == SVX_NUM_CHAR_SPECIAL;
1442 bShowBitmap &= (aNumFmtArr[i]->GetNumberingType()&(~LINK_TOKEN)) == SVX_NUM_BITMAP;
1443 if(USHRT_MAX == nLvl)
1445 nLvl = i;
1446 sFirstCharFmt = aNumFmtArr[i]->GetCharFmtName();
1447 eFirstOrient = aNumFmtArr[i]->GetVertOrient();
1448 if(bShowBitmap)
1449 aFirstSize = aNumFmtArr[i]->GetGraphicSize();
1451 if( i > nLvl)
1453 bSameType &= aNumFmtArr[i]->GetNumberingType() == aNumFmtArr[nLvl]->GetNumberingType();
1454 bSameStart = aNumFmtArr[i]->GetStart() == aNumFmtArr[nLvl]->GetStart();
1456 bSamePrefix = aNumFmtArr[i]->GetPrefix() == aNumFmtArr[nLvl]->GetPrefix();
1457 bSameSuffix = aNumFmtArr[i]->GetSuffix() == aNumFmtArr[nLvl]->GetSuffix();
1458 bAllLevel &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[nLvl]->GetIncludeUpperLevels();
1459 bSameCharFmt &= sFirstCharFmt == aNumFmtArr[i]->GetCharFmtName();
1460 bSameVOrient &= eFirstOrient == aNumFmtArr[i]->GetVertOrient();
1461 if(bShowBitmap && bSameSize)
1462 bSameSize &= aNumFmtArr[i]->GetGraphicSize() == aFirstSize;
1463 bSameBulColor &= aNumFmtArr[i]->GetBulletColor() == aNumFmtArr[nLvl]->GetBulletColor();
1464 bSameBulRelSize &= aNumFmtArr[i]->GetBulletRelSize() == aNumFmtArr[nLvl]->GetBulletRelSize();
1465 bSameAdjust &= aNumFmtArr[i]->GetNumAdjust() == aNumFmtArr[nLvl]->GetNumAdjust();
1467 nHighestLevel = i;
1469 else
1470 aNumFmtArr[i] = 0;
1472 nMask <<= 1 ;
1475 SwitchNumberType(bShowBullet ? 1 : bShowBitmap ? 2 : 0);
1476 CheckForStartValue_Impl(aNumFmtArr[nLvl]->GetNumberingType());
1477 if(bShowBitmap)
1479 if(!bSameVOrient || eFirstOrient == text::VertOrientation::NONE)
1480 m_pOrientLB->SetNoSelection();
1481 else
1482 m_pOrientLB->SelectEntryPos(
1483 sal::static_int_cast< sal_uInt16 >(eFirstOrient - 1));
1484 // no text::VertOrientation::NONE
1486 if(bSameSize)
1488 SetMetricValue(*m_pHeightMF, aFirstSize.Height(), eCoreUnit);
1489 SetMetricValue(*m_pWidthMF, aFirstSize.Width(), eCoreUnit);
1491 else
1493 m_pHeightMF->SetText(aEmptyStr);
1494 m_pWidthMF->SetText(aEmptyStr);
1498 if(bSameType)
1500 sal_uInt16 nLBData = (sal_uInt16) aNumFmtArr[nLvl]->GetNumberingType();
1501 m_pFmtLB->SelectEntryPos(m_pFmtLB->GetEntryPos( (void*)sal::static_int_cast<sal_uIntPtr>( nLBData ) ));
1503 else
1504 m_pFmtLB->SetNoSelection();
1506 m_pAllLevelNF->Enable(nHighestLevel > 0 && !m_pSameLevelCB->IsChecked());
1507 m_pAllLevelNF->SetMax(nHighestLevel + 1);
1508 if(bAllLevel)
1510 m_pAllLevelNF->SetValue(aNumFmtArr[nLvl]->GetIncludeUpperLevels());
1512 else
1514 m_pAllLevelNF->SetText(aEmptyStr);
1516 if(bSameAdjust)
1518 sal_uInt16 nPos = 1; // centered
1519 if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_LEFT)
1520 nPos = 0;
1521 else if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_RIGHT)
1522 nPos = 2;
1523 m_pAlignLB->SelectEntryPos(nPos);
1525 else
1527 m_pAlignLB->SetNoSelection();
1530 if(bBullRelSize)
1532 if(bSameBulRelSize)
1533 m_pBulRelSizeMF->SetValue(aNumFmtArr[nLvl]->GetBulletRelSize());
1534 else
1535 m_pBulRelSizeMF->SetText(aEmptyStr);
1537 if(bBullColor)
1539 if(bSameBulColor)
1540 m_pBulColLB->SelectEntry(aNumFmtArr[nLvl]->GetBulletColor());
1541 else
1542 m_pBulColLB->SetNoSelection();
1544 switch(nBullet)
1546 case SHOW_NUMBERING:
1547 if(bSameStart)
1549 m_pStartED->SetValue(aNumFmtArr[nLvl]->GetStart());
1551 else
1552 m_pStartED->SetText(aEmptyStr);
1553 break;
1554 case SHOW_BULLET:
1555 break;
1556 case SHOW_BITMAP:
1557 break;
1560 if(bSamePrefix)
1561 m_pPrefixED->SetText(aNumFmtArr[nLvl]->GetPrefix());
1562 else
1563 m_pPrefixED->SetText(aEmptyStr);
1564 if(bSameSuffix)
1565 m_pSuffixED->SetText(aNumFmtArr[nLvl]->GetSuffix());
1566 else
1567 m_pSuffixED->SetText(aEmptyStr);
1569 if(bSameCharFmt)
1571 if(sFirstCharFmt.Len())
1572 m_pCharFmtLB->SelectEntry(sFirstCharFmt);
1573 else
1574 m_pCharFmtLB->SelectEntryPos( 0 );
1576 else
1577 m_pCharFmtLB->SetNoSelection();
1579 m_pPreviewWIN->SetLevel(nActNumLvl);
1580 m_pPreviewWIN->Invalidate();
1583 // 0 - Number; 1 - Bullet; 2 - Bitmap
1584 void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType, sal_Bool )
1586 if(nBullet == nType)
1587 return;
1588 nBullet = nType;
1589 sal_Bool bBullet = (nType == SHOW_BULLET);
1590 sal_Bool bBitmap = (nType == SHOW_BITMAP);
1591 sal_Bool bEnableBitmap = (nType == SHOW_BITMAP);
1592 sal_Bool bNumeric = !(bBitmap||bBullet);
1593 m_pSeparatorFT->Show(bNumeric);
1594 m_pPrefixFT->Show(bNumeric);
1595 m_pPrefixED->Show(bNumeric);
1596 m_pSuffixFT->Show(bNumeric);
1597 m_pSuffixED->Show(bNumeric);
1599 sal_Bool bCharFmt = pActNum->IsFeatureSupported(NUM_CHAR_STYLE);
1600 m_pCharFmtFT->Show(!bBitmap && bCharFmt);
1601 m_pCharFmtLB->Show(!bBitmap && bCharFmt);
1603 // this is rather misusage, as there is no own flag
1604 // for complete numeration
1605 sal_Bool bAllLevelFeature = pActNum->IsFeatureSupported(NUM_CONTINUOUS);
1606 sal_Bool bAllLevel = bNumeric && bAllLevelFeature && !bHTMLMode;
1607 m_pAllLevelFT->Show(bAllLevel);
1608 m_pAllLevelNF->Show(bAllLevel);
1610 m_pStartFT->Show(!(bBullet||bBitmap));
1611 m_pStartED->Show(!(bBullet||bBitmap));
1613 m_pBulletFT->Show(bBullet);
1614 m_pBulletPB->Show(bBullet);
1615 sal_Bool bBullColor = pActNum->IsFeatureSupported(NUM_BULLET_COLOR);
1616 m_pBulColorFT->Show(!bBitmap && bBullColor);
1617 m_pBulColLB->Show(!bBitmap && bBullColor);
1618 sal_Bool bBullResSize = pActNum->IsFeatureSupported(NUM_BULLET_REL_SIZE);
1619 m_pBulRelSizeFT->Show(!bBitmap && bBullResSize);
1620 m_pBulRelSizeMF->Show(!bBitmap && bBullResSize);
1622 m_pBitmapFT->Show(bBitmap);
1623 m_pBitmapMB->Show(bBitmap);
1625 m_pWidthFT->Show(bBitmap);
1626 m_pWidthMF->Show(bBitmap);
1627 m_pHeightFT->Show(bBitmap);
1628 m_pHeightMF->Show(bBitmap);
1629 m_pRatioCB->Show(bBitmap);
1631 m_pOrientFT->Show(bBitmap && bAllLevelFeature);
1632 m_pOrientLB->Show(bBitmap && bAllLevelFeature);
1634 m_pWidthFT->Enable(bEnableBitmap);
1635 m_pWidthMF->Enable(bEnableBitmap);
1636 m_pHeightFT->Enable(bEnableBitmap);
1637 m_pHeightMF->Enable(bEnableBitmap);
1638 m_pRatioCB->Enable(bEnableBitmap);
1639 m_pOrientFT->Enable(bEnableBitmap);
1640 m_pOrientLB->Enable(bEnableBitmap);
1643 IMPL_LINK( SvxNumOptionsTabPage, LevelHdl_Impl, ListBox *, pBox )
1645 sal_uInt16 nSaveNumLvl = nActNumLvl;
1646 nActNumLvl = 0;
1647 if(pBox->IsEntryPosSelected( pActNum->GetLevelCount() ) &&
1648 (pBox->GetSelectEntryCount() == 1 || nSaveNumLvl != 0xffff))
1650 nActNumLvl = 0xFFFF;
1651 pBox->SetUpdateMode(sal_False);
1652 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1653 pBox->SelectEntryPos( i, sal_False );
1654 pBox->SetUpdateMode(sal_True);
1656 else if(pBox->GetSelectEntryCount())
1658 sal_uInt16 nMask = 1;
1659 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1661 if(pBox->IsEntryPosSelected( i ))
1662 nActNumLvl |= nMask;
1663 nMask <<= 1;
1665 pBox->SelectEntryPos( pActNum->GetLevelCount(), sal_False );
1667 else
1669 nActNumLvl = nSaveNumLvl;
1670 sal_uInt16 nMask = 1;
1671 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1673 if(nActNumLvl & nMask)
1675 pBox->SelectEntryPos(i);
1676 break;
1678 nMask <<=1;
1681 InitControls();
1682 return 0;
1685 IMPL_LINK_NOARG(SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl)
1687 m_pPreviewWIN->Invalidate();
1688 return 0;
1691 IMPL_LINK( SvxNumOptionsTabPage, AllLevelHdl_Impl, NumericField*, pBox )
1693 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1695 sal_uInt16 nMask = 1;
1696 for(sal_uInt16 e = 0; e < pActNum->GetLevelCount(); e++)
1698 if(nActNumLvl & nMask)
1700 SvxNumberFormat aNumFmt(pActNum->GetLevel(e));
1701 aNumFmt.SetIncludeUpperLevels((sal_uInt8) std::min(pBox->GetValue(), sal_Int64(e + 1)) );
1702 pActNum->SetLevel(e, aNumFmt);
1704 nMask <<= 1;
1707 SetModified();
1708 return 0;
1711 IMPL_LINK( SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, ListBox *, pBox )
1713 String sSelectStyle;
1714 sal_Bool bShowOrient = sal_False;
1715 sal_Bool bBmp = sal_False;
1716 String aEmptyStr;
1717 sal_uInt16 nMask = 1;
1718 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1720 if(nActNumLvl & nMask)
1722 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1723 // PAGEDESC does not exist
1724 sal_uInt16 nNumType = (sal_uInt16)(sal_uLong)pBox->GetEntryData(pBox->GetSelectEntryPos());
1725 aNumFmt.SetNumberingType((sal_Int16)nNumType);
1726 sal_uInt16 nNumberingType = aNumFmt.GetNumberingType();
1727 if(SVX_NUM_BITMAP == (nNumberingType&(~LINK_TOKEN)))
1729 bBmp |= 0 != aNumFmt.GetBrush();
1730 aNumFmt.SetIncludeUpperLevels( sal_False );
1731 aNumFmt.SetSuffix( aEmptyStr );
1732 aNumFmt.SetPrefix( aEmptyStr );
1733 if(!bBmp)
1734 aNumFmt.SetGraphic(aEmptyStr);
1735 pActNum->SetLevel(i, aNumFmt);
1736 SwitchNumberType(SHOW_BITMAP, bBmp );
1737 bShowOrient = sal_True;
1739 else if( SVX_NUM_CHAR_SPECIAL == nNumberingType )
1741 aNumFmt.SetIncludeUpperLevels( sal_False );
1742 aNumFmt.SetSuffix( aEmptyStr );
1743 aNumFmt.SetPrefix( aEmptyStr );
1744 if( !aNumFmt.GetBulletFont() )
1745 aNumFmt.SetBulletFont(&aActBulletFont);
1746 if( !aNumFmt.GetBulletChar() )
1747 aNumFmt.SetBulletChar( SVX_DEF_BULLET );
1748 pActNum->SetLevel(i, aNumFmt);
1749 SwitchNumberType(SHOW_BULLET);
1750 // allocation of the drawing pattern is automatic
1751 if(bAutomaticCharStyles)
1753 sSelectStyle = m_sBulletCharFmtName;
1756 else
1758 aNumFmt.SetPrefix( m_pPrefixED->GetText() );
1759 aNumFmt.SetSuffix( m_pSuffixED->GetText() );
1760 SwitchNumberType(SHOW_NUMBERING);
1761 pActNum->SetLevel(i, aNumFmt);
1762 CheckForStartValue_Impl(nNumberingType);
1764 // allocation of the drawing pattern is automatic
1765 if(bAutomaticCharStyles)
1767 sSelectStyle = m_sNumCharFmtName;
1771 nMask <<= 1;
1773 sal_Bool bAllLevelFeature = pActNum->IsFeatureSupported(NUM_CONTINUOUS);
1774 if(bShowOrient && bAllLevelFeature)
1776 m_pOrientFT->Show();
1777 m_pOrientLB->Show();
1779 else
1781 m_pOrientFT->Hide();
1782 m_pOrientLB->Hide();
1784 SetModified();
1785 if(sSelectStyle.Len())
1787 m_pCharFmtLB->SelectEntry(sSelectStyle);
1788 CharFmtHdl_Impl(m_pCharFmtLB);
1789 bAutomaticCharStyles = sal_True;
1791 return 0;
1794 void SvxNumOptionsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType)
1796 sal_Bool bIsNull = m_pStartED->GetValue() == 0;
1797 sal_Bool bNoZeroAllowed = nNumberingType < SVX_NUM_ARABIC ||
1798 SVX_NUM_CHARS_UPPER_LETTER_N == nNumberingType ||
1799 SVX_NUM_CHARS_LOWER_LETTER_N == nNumberingType;
1800 m_pStartED->SetMin(bNoZeroAllowed ? 1 : 0);
1801 if(bIsNull && bNoZeroAllowed)
1802 m_pStartED->GetModifyHdl().Call(m_pStartED);
1805 IMPL_LINK( SvxNumOptionsTabPage, OrientHdl_Impl, ListBox *, pBox )
1807 sal_uInt16 nPos = pBox->GetSelectEntryPos();
1808 nPos ++; // no VERT_NONE
1810 sal_uInt16 nMask = 1;
1811 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1813 if(nActNumLvl & nMask)
1815 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1816 if(SVX_NUM_BITMAP == (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
1818 const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
1819 const Size& rSize = aNumFmt.GetGraphicSize();
1820 sal_Int16 eOrient = (sal_Int16)nPos;
1821 aNumFmt.SetGraphicBrush( pBrushItem, &rSize, &eOrient );
1822 pActNum->SetLevel(i, aNumFmt);
1825 nMask <<= 1;
1827 SetModified(sal_False);
1828 return 0;
1832 IMPL_LINK( SvxNumOptionsTabPage, SameLevelHdl_Impl, CheckBox *, pBox )
1834 sal_Bool bSet = pBox->IsChecked();
1835 pActNum->SetContinuousNumbering(bSet);
1836 sal_Bool bRepaint = sal_False;
1837 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1839 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1840 if(aNumFmt.GetNumberingType() != SVX_NUM_NUMBER_NONE)
1842 bRepaint = sal_True;
1843 break;
1846 SetModified(bRepaint);
1847 InitControls();
1848 return 0;
1851 IMPL_LINK( SvxNumOptionsTabPage, BulColorHdl_Impl, ColorListBox*, pBox )
1853 Color nSetColor = pBox->GetSelectEntryColor();
1855 sal_uInt16 nMask = 1;
1856 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1858 if(nActNumLvl & nMask)
1860 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1861 aNumFmt.SetBulletColor(nSetColor);
1862 pActNum->SetLevel(i, aNumFmt);
1864 nMask <<= 1;
1866 SetModified();
1867 return 0;
1870 IMPL_LINK( SvxNumOptionsTabPage, BulRelSizeHdl_Impl, MetricField *, pField)
1872 sal_uInt16 nRelSize = (sal_uInt16)pField->GetValue();
1874 sal_uInt16 nMask = 1;
1875 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1877 if(nActNumLvl & nMask)
1879 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1880 aNumFmt.SetBulletRelSize(nRelSize);
1881 pActNum->SetLevel(i, aNumFmt);
1883 nMask <<= 1;
1885 SetModified();
1886 return 0;
1889 IMPL_LINK( SvxNumOptionsTabPage, GraphicHdl_Impl, MenuButton *, pButton )
1891 sal_uInt16 nItemId = pButton->GetCurItemId();
1892 String aGrfName;
1893 Size aSize;
1894 sal_Bool bSucc(sal_False);
1895 SvxOpenGraphicDialog aGrfDlg( CUI_RES(RID_SVXSTR_EDIT_GRAPHIC) );
1897 if(MN_GALLERY_ENTRY <= nItemId )
1899 sal_uInt16 idx = nItemId - MN_GALLERY_ENTRY;
1900 if (idx < aGrfNames.size())
1902 aGrfName = aGrfNames[idx];
1903 Graphic aGraphic;
1904 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, idx, &aGraphic))
1906 aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
1907 bSucc = sal_True;
1911 else
1913 aGrfDlg.EnableLink( sal_False );
1914 aGrfDlg.AsLink( sal_False );
1915 if ( !aGrfDlg.Execute() )
1917 // memorize selected filter
1918 aGrfName = aGrfDlg.GetPath();
1920 Graphic aGraphic;
1921 if( !aGrfDlg.GetGraphic(aGraphic) )
1923 aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
1924 bSucc = sal_True;
1928 if(bSucc)
1930 aSize = OutputDevice::LogicToLogic(aSize, MAP_100TH_MM, (MapUnit)eCoreUnit);
1932 sal_uInt16 nMask = 1;
1933 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1935 if(nActNumLvl & nMask)
1937 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1938 aNumFmt.SetCharFmtName(m_sNumCharFmtName);
1939 aNumFmt.SetGraphic(aGrfName);
1941 // set size for a later comparison
1942 const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
1943 // initiate asynchronous loading
1944 sal_Int16 eOrient = aNumFmt.GetVertOrient();
1945 aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient );
1946 aInitSize[i] = aNumFmt.GetGraphicSize();
1948 pActNum->SetLevel(i, aNumFmt);
1950 nMask <<= 1;
1952 m_pRatioCB->Enable();
1953 m_pWidthFT->Enable();
1954 m_pHeightFT->Enable();
1955 m_pWidthMF->Enable();
1956 m_pHeightMF->Enable();
1957 SetMetricValue(*m_pWidthMF, aSize.Width(), eCoreUnit);
1958 SetMetricValue(*m_pHeightMF, aSize.Height(), eCoreUnit);
1959 m_pOrientFT->Enable();
1960 m_pOrientLB->Enable();
1961 SetModified();
1962 //needed due to asynchronous loading of graphics in the SvxBrushItem
1963 aInvalidateTimer.Start();
1965 return 0;
1968 IMPL_LINK_NOARG(SvxNumOptionsTabPage, PopupActivateHdl_Impl)
1970 if(!bMenuButtonInitialized)
1972 bMenuButtonInitialized = sal_True;
1973 EnterWait();
1974 PopupMenu* pMenu = m_pBitmapMB->GetPopupMenu();
1975 PopupMenu* pPopup = pMenu->GetPopupMenu(m_nGalleryId);
1977 if (GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames))
1979 pPopup->Clear();
1980 GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS);
1982 Graphic aGraphic;
1983 String sGrfName;
1984 std::vector<String>::const_iterator it = aGrfNames.begin();
1985 for(sal_uInt16 i = 0; it != aGrfNames.end(); ++it, ++i)
1987 sGrfName = *it;
1988 INetURLObject aObj(sGrfName);
1989 if(aObj.GetProtocol() == INET_PROT_FILE)
1990 sGrfName = aObj.PathToFileName();
1992 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, i, &aGraphic))
1994 Bitmap aBitmap(aGraphic.GetBitmap());
1995 Size aSize(aBitmap.GetSizePixel());
1996 if(aSize.Width() > MAX_BMP_WIDTH ||
1997 aSize.Height() > MAX_BMP_HEIGHT)
1999 sal_Bool bWidth = aSize.Width() > aSize.Height();
2000 double nScale = bWidth ?
2001 (double)MAX_BMP_WIDTH / (double)aSize.Width():
2002 (double)MAX_BMP_HEIGHT / (double)aSize.Height();
2003 aBitmap.Scale(nScale, nScale);
2005 Image aImage(aBitmap);
2007 pPopup->InsertItem(MN_GALLERY_ENTRY + i, sGrfName, aImage );
2009 else
2011 Image aImage;
2012 pPopup->InsertItem(
2013 MN_GALLERY_ENTRY + i, sGrfName, aImage );
2016 GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS);
2018 LeaveWait();
2020 return 0;
2023 IMPL_LINK_NOARG(SvxNumOptionsTabPage, BulletHdl_Impl)
2025 SvxCharacterMap* pMap = new SvxCharacterMap( this, sal_True );
2027 sal_uInt16 nMask = 1;
2028 const Font* pFmtFont = 0;
2029 sal_Bool bSameBullet = sal_True;
2030 sal_Unicode cBullet = 0;
2031 sal_Bool bFirst = sal_True;
2032 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2034 if(nActNumLvl & nMask)
2036 const SvxNumberFormat& rCurFmt = pActNum->GetLevel(i);
2037 if(bFirst)
2039 cBullet = rCurFmt.GetBulletChar();
2041 else if(rCurFmt.GetBulletChar() != cBullet )
2043 bSameBullet = sal_False;
2044 break;
2046 if(!pFmtFont)
2047 pFmtFont = rCurFmt.GetBulletFont();
2048 bFirst = sal_False;
2050 nMask <<= 1;
2054 if(pFmtFont)
2055 pMap->SetCharFont(*pFmtFont);
2056 else
2057 pMap->SetCharFont(aActBulletFont);
2058 if(bSameBullet)
2059 pMap->SetChar( cBullet );
2060 if(pMap->Execute() == RET_OK)
2062 // change Font Numrules
2063 aActBulletFont = pMap->GetCharFont();
2065 sal_uInt16 _nMask = 1;
2066 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2068 if(nActNumLvl & _nMask)
2070 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2071 aNumFmt.SetBulletFont(&aActBulletFont); ;
2072 aNumFmt.SetBulletChar( (sal_Unicode) pMap->GetChar() );
2073 pActNum->SetLevel(i, aNumFmt);
2075 _nMask <<= 1;
2078 SetModified();
2080 delete pMap;
2081 return 0;
2084 IMPL_LINK( SvxNumOptionsTabPage, SizeHdl_Impl, MetricField *, pField)
2086 sal_Bool bWidth = pField == m_pWidthMF;
2087 bLastWidthModified = bWidth;
2088 sal_Bool bRatio = m_pRatioCB->IsChecked();
2089 long nWidthVal = static_cast<long>(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_100TH_MM)));
2090 long nHeightVal = static_cast<long>(m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_100TH_MM)));
2091 nWidthVal = OutputDevice::LogicToLogic( nWidthVal ,
2092 MAP_100TH_MM, (MapUnit)eCoreUnit );
2093 nHeightVal = OutputDevice::LogicToLogic( nHeightVal,
2094 MAP_100TH_MM, (MapUnit)eCoreUnit);
2095 double fSizeRatio;
2097 sal_Bool bRepaint = sal_False;
2098 sal_uInt16 nMask = 1;
2099 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2101 if(nActNumLvl & nMask)
2103 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2104 if(SVX_NUM_BITMAP == (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
2106 Size aSize(aNumFmt.GetGraphicSize() );
2107 Size aSaveSize(aSize);
2109 if (aInitSize[i].Height())
2110 fSizeRatio = (double)aInitSize[i].Width() / (double)aInitSize[i].Height();
2111 else
2112 fSizeRatio = (double)1;
2114 if(bWidth)
2116 long nDelta = nWidthVal - aInitSize[i].Width();
2117 aSize.Width() = nWidthVal;
2118 if (bRatio)
2120 aSize.Height() = aInitSize[i].Height() + (long)((double)nDelta / fSizeRatio);
2121 m_pHeightMF->SetUserValue(m_pHeightMF->Normalize(
2122 OutputDevice::LogicToLogic( aSize.Height(), (MapUnit)eCoreUnit, MAP_100TH_MM )),
2123 FUNIT_100TH_MM);
2126 else
2128 long nDelta = nHeightVal - aInitSize[i].Height();
2129 aSize.Height() = nHeightVal;
2130 if (bRatio)
2132 aSize.Width() = aInitSize[i].Width() + (long)((double)nDelta * fSizeRatio);
2133 m_pWidthMF->SetUserValue(m_pWidthMF->Normalize(
2134 OutputDevice::LogicToLogic( aSize.Width(), (MapUnit)eCoreUnit, MAP_100TH_MM )),
2135 FUNIT_100TH_MM);
2138 const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
2139 sal_Int16 eOrient = aNumFmt.GetVertOrient();
2140 if(aSize != aSaveSize)
2141 bRepaint = sal_True;
2142 aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient );
2143 pActNum->SetLevel(i, aNumFmt);
2146 nMask <<= 1;
2148 SetModified(bRepaint);
2149 return 0;
2152 IMPL_LINK( SvxNumOptionsTabPage, RatioHdl_Impl, CheckBox *, pBox )
2154 if (pBox->IsChecked())
2156 if (bLastWidthModified)
2157 SizeHdl_Impl(m_pWidthMF);
2158 else
2159 SizeHdl_Impl(m_pHeightMF);
2161 return 0;
2164 IMPL_LINK_NOARG(SvxNumOptionsTabPage, CharFmtHdl_Impl)
2166 bAutomaticCharStyles = sal_False;
2167 sal_uInt16 nEntryPos = m_pCharFmtLB->GetSelectEntryPos();
2168 String sEntry = m_pCharFmtLB->GetSelectEntry();
2169 sal_uInt16 nMask = 1;
2170 String aEmptyStr;
2171 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2173 if(nActNumLvl & nMask)
2175 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2176 if( 0 == nEntryPos )
2177 aNumFmt.SetCharFmtName(aEmptyStr);
2178 else
2180 if(SVX_NUM_BITMAP != (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
2181 aNumFmt.SetCharFmtName(sEntry);
2183 pActNum->SetLevel(i, aNumFmt);
2185 nMask <<= 1;
2187 SetModified(sal_False);
2188 return 0;
2192 IMPL_LINK( SvxNumOptionsTabPage, EditModifyHdl_Impl, Edit *, pEdit )
2194 sal_Bool bPrefix = pEdit == m_pPrefixED;
2195 sal_Bool bSuffix = pEdit == m_pSuffixED;
2196 sal_Bool bStart = pEdit == m_pStartED;
2197 sal_uInt16 nMask = 1;
2198 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2200 if(nActNumLvl & nMask)
2202 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2203 if(bPrefix)
2204 aNumFmt.SetPrefix( m_pPrefixED->GetText() );
2205 else if(bSuffix)
2206 aNumFmt.SetSuffix( m_pSuffixED->GetText() );
2207 else if(bStart)
2208 aNumFmt.SetStart( (sal_uInt16)m_pStartED->GetValue() );
2209 else //align
2211 sal_uInt16 nPos = m_pAlignLB->GetSelectEntryPos();
2212 SvxAdjust eAdjust = SVX_ADJUST_CENTER;
2213 if(nPos == 0)
2214 eAdjust = SVX_ADJUST_LEFT;
2215 else if(nPos == 2)
2216 eAdjust = SVX_ADJUST_RIGHT;
2217 aNumFmt.SetNumAdjust( eAdjust );
2219 pActNum->SetLevel(i, aNumFmt);
2221 nMask <<= 1;
2223 SetModified();
2225 return 0;
2228 static sal_uInt16 lcl_DrawGraphic(VirtualDevice* pVDev, const SvxNumberFormat &rFmt, sal_uInt16 nXStart,
2229 sal_uInt16 nYStart, sal_uInt16 nDivision)
2231 const SvxBrushItem* pBrushItem = rFmt.GetBrush();
2232 sal_uInt16 nRet = 0;
2233 if(pBrushItem)
2235 const Graphic* pGrf = pBrushItem->GetGraphic();
2236 if(pGrf)
2238 Size aGSize( rFmt.GetGraphicSize() );
2239 aGSize.Width() /= nDivision;
2240 nRet = (sal_uInt16)aGSize.Width();
2241 aGSize.Height() /= nDivision;
2242 pGrf->Draw( pVDev, Point(nXStart,nYStart),
2243 pVDev->PixelToLogic( aGSize ) );
2246 return nRet;
2250 static sal_uInt16 lcl_DrawBullet(VirtualDevice* pVDev,
2251 const SvxNumberFormat& rFmt, sal_uInt16 nXStart,
2252 sal_uInt16 nYStart, const Size& rSize)
2254 Font aTmpFont(pVDev->GetFont());
2256 // via Uno it's possible that no font has been set!
2257 Font aFont(rFmt.GetBulletFont() ? *rFmt.GetBulletFont() : aTmpFont);
2258 Size aTmpSize(rSize);
2259 aTmpSize.Width() *= rFmt.GetBulletRelSize();
2260 aTmpSize.Width() /= 100 ;
2261 aTmpSize.Height() *= rFmt.GetBulletRelSize();
2262 aTmpSize.Height() /= 100 ;
2263 // in case of a height of zero it is drawed in original height
2264 if(!aTmpSize.Height())
2265 aTmpSize.Height() = 1;
2266 aFont.SetSize(aTmpSize);
2267 aFont.SetTransparent(sal_True);
2268 Color aBulletColor = rFmt.GetBulletColor();
2269 if(aBulletColor.GetColor() == COL_AUTO)
2270 aBulletColor = Color(pVDev->GetFillColor().IsDark() ? COL_WHITE : COL_BLACK);
2271 else if(aBulletColor == pVDev->GetFillColor())
2272 aBulletColor.Invert();
2273 aFont.SetColor(aBulletColor);
2274 pVDev->SetFont( aFont );
2275 OUString aText(rFmt.GetBulletChar());
2276 long nY = nYStart;
2277 nY -= ((aTmpSize.Height() - rSize.Height())/ 2);
2278 pVDev->DrawText( Point(nXStart, nY), aText );
2279 sal_uInt16 nRet = (sal_uInt16)pVDev->GetTextWidth(aText);
2281 pVDev->SetFont(aTmpFont);
2282 return nRet;
2285 SvxNumberingPreview::SvxNumberingPreview(Window* pParent, WinBits nWinBits)
2286 : Window(pParent, nWinBits)
2287 , pActNum(0)
2288 , nPageWidth(0)
2289 , pOutlineNames(0)
2290 , bPosition(false)
2291 , nActLevel(USHRT_MAX)
2293 SetBorderStyle(WINDOW_BORDER_MONO);
2296 extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSvxNumberingPreview(Window *pParent, VclBuilder::stringmap &)
2298 return new SvxNumberingPreview(pParent, WB_BORDER);
2301 // paint preview of numeration
2302 void SvxNumberingPreview::Paint( const Rectangle& /*rRect*/ )
2304 Size aSize(PixelToLogic(GetOutputSizePixel()));
2305 Rectangle aRect(Point(0,0), aSize);
2307 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2308 const Color aBackColor = rStyleSettings.GetFieldColor();
2309 const Color aTextColor = rStyleSettings.GetFieldTextColor();
2311 VirtualDevice* pVDev = new VirtualDevice(*this);
2312 pVDev->EnableRTL( IsRTLEnabled() );
2313 pVDev->SetMapMode(GetMapMode());
2314 pVDev->SetOutputSize( aSize );
2316 Color aLineColor(COL_LIGHTGRAY);
2317 if(aLineColor == aBackColor)
2318 aLineColor.Invert();
2319 pVDev->SetLineColor(aLineColor);
2320 pVDev->SetFillColor( aBackColor );
2321 pVDev->DrawRect(aRect);
2323 if(pActNum)
2325 sal_uInt16 nWidthRelation;
2326 if(nPageWidth)
2328 nWidthRelation = sal_uInt16 (nPageWidth / aSize.Width());
2329 if(bPosition)
2330 nWidthRelation = nWidthRelation * 2 / 3;
2331 else
2332 nWidthRelation = nWidthRelation / 4;
2334 else
2335 nWidthRelation = 30; // chapter dialog
2337 // height per level
2338 sal_uInt16 nXStep = sal::static_int_cast< sal_uInt16 >(aSize.Width() / (3 * pActNum->GetLevelCount()));
2339 if(pActNum->GetLevelCount() < 10)
2340 nXStep /= 2;
2341 sal_uInt16 nYStart = 4;
2342 // the whole height mustn't be used for a single level
2343 sal_uInt16 nYStep = sal::static_int_cast< sal_uInt16 >((aSize.Height() - 6)/ (pActNum->GetLevelCount() > 1 ? pActNum->GetLevelCount() : 5));
2344 aStdFont = OutputDevice::GetDefaultFont(
2345 DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE);
2346 aStdFont.SetColor(aTextColor);
2347 aStdFont.SetFillColor(aBackColor);
2349 sal_uInt16 nFontHeight = nYStep * 6 / 10;
2350 if(bPosition)
2351 nFontHeight = nYStep * 15 / 10;
2352 aStdFont.SetSize(Size( 0, nFontHeight ));
2354 SvxNodeNum aNum( (sal_uInt8)0 );
2355 sal_uInt16 nPreNum = pActNum->GetLevel(0).GetStart();
2357 if(bPosition)
2359 sal_uInt16 nLineHeight = nFontHeight * 8 / 7;
2360 sal_uInt8 nStart = 0;
2361 while( !(nActLevel & (1<<nStart)) )
2363 nStart++;
2365 if(nStart)
2366 nStart--;
2367 sal_uInt8 nEnd = std::min( (sal_uInt8)(nStart + 3), (sal_uInt8)pActNum->GetLevelCount() );
2368 for( sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel )
2370 const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel);
2371 aNum.GetLevelVal()[ nLevel ] = rFmt.GetStart();
2373 sal_uInt16 nXStart( 0 );
2374 short nTextOffset( 0 );
2375 sal_uInt16 nNumberXPos( 0 );
2376 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2378 nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
2379 nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation;
2380 nNumberXPos = nXStart;
2381 sal_uInt16 nFirstLineOffset = (-rFmt.GetFirstLineOffset()) / nWidthRelation;
2383 if(nFirstLineOffset <= nNumberXPos)
2384 nNumberXPos = nNumberXPos - nFirstLineOffset;
2385 else
2386 nNumberXPos = 0;
2387 // in draw this is valid
2388 if(nTextOffset < 0)
2389 nNumberXPos = nNumberXPos + nTextOffset;
2391 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
2393 const long nTmpNumberXPos( ( rFmt.GetIndentAt() +
2394 rFmt.GetFirstLineIndent() ) /
2395 nWidthRelation );
2396 if ( nTmpNumberXPos < 0 )
2398 nNumberXPos = 0;
2400 else
2402 nNumberXPos = static_cast<sal_uInt16>( nTmpNumberXPos );
2406 sal_uInt16 nBulletWidth = 0;
2407 if( SVX_NUM_BITMAP == (rFmt.GetNumberingType() &(~LINK_TOKEN)))
2409 nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawGraphic(pVDev, rFmt,
2410 nNumberXPos,
2411 nYStart, nWidthRelation) : 0;
2413 else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
2415 nBulletWidth = rFmt.IsShowSymbol() ?
2416 lcl_DrawBullet(pVDev, rFmt, nNumberXPos, nYStart, aStdFont.GetSize()) : 0;
2418 else
2420 pVDev->SetFont(aStdFont);
2421 aNum.SetLevel( nLevel );
2422 if(pActNum->IsContinuousNumbering())
2423 aNum.GetLevelVal()[nLevel] = nPreNum;
2424 String aText(pActNum->MakeNumString( aNum ));
2425 Font aSaveFont = pVDev->GetFont();
2426 Font aColorFont(aSaveFont);
2427 Color aTmpBulletColor = rFmt.GetBulletColor();
2428 if(aTmpBulletColor.GetColor() == COL_AUTO)
2429 aTmpBulletColor = Color(aBackColor.IsDark() ? COL_WHITE : COL_BLACK);
2430 else if(aTmpBulletColor == aBackColor)
2431 aTmpBulletColor.Invert();
2432 aColorFont.SetColor(aTmpBulletColor);
2433 pVDev->SetFont(aColorFont);
2434 pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
2435 pVDev->SetFont(aSaveFont);
2436 nBulletWidth = (sal_uInt16)pVDev->GetTextWidth(aText);
2437 nPreNum++;
2439 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT &&
2440 rFmt.GetLabelFollowedBy() == SvxNumberFormat::SPACE )
2442 pVDev->SetFont(aStdFont);
2443 OUString aText(' ');
2444 pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
2445 nBulletWidth = nBulletWidth + (sal_uInt16)pVDev->GetTextWidth(aText);
2448 sal_uInt16 nTextXPos( 0 );
2449 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2451 nTextXPos = nXStart;
2452 if(nTextOffset < 0)
2453 nTextXPos = nTextXPos + nTextOffset;
2454 if(nNumberXPos + nBulletWidth + nTextOffset > nTextXPos )
2455 nTextXPos = nNumberXPos + nBulletWidth + nTextOffset;
2457 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
2459 switch ( rFmt.GetLabelFollowedBy() )
2461 case SvxNumberFormat::LISTTAB:
2463 nTextXPos = static_cast<sal_uInt16>(
2464 rFmt.GetListtabPos() / nWidthRelation );
2465 if ( nTextXPos < nNumberXPos + nBulletWidth )
2467 nTextXPos = nNumberXPos + nBulletWidth;
2470 break;
2471 case SvxNumberFormat::SPACE:
2472 case SvxNumberFormat::NOTHING:
2474 nTextXPos = nNumberXPos + nBulletWidth;
2476 break;
2479 nXStart = static_cast<sal_uInt16>( rFmt.GetIndentAt() / nWidthRelation );
2482 Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2));
2483 pVDev->SetFillColor( aBackColor );
2484 pVDev->DrawRect( aRect1 );
2486 Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2));
2487 pVDev->DrawRect( aRect2 );
2488 nYStart += 2 * nLineHeight;
2491 else
2493 //#i5153# painting gray or black rectangles as 'normal' numbering text
2494 OUString sMsg( "Preview" );
2495 long nWidth = pVDev->GetTextWidth(sMsg);
2496 long nTextHeight = pVDev->GetTextHeight();
2497 long nRectHeight = nTextHeight * 2 / 3;
2498 long nTopOffset = nTextHeight - nRectHeight;
2499 Color aBlackColor(COL_BLACK);
2500 if(aBlackColor == aBackColor)
2501 aBlackColor.Invert();
2503 for( sal_uInt8 nLevel = 0; nLevel < pActNum->GetLevelCount();
2504 ++nLevel, nYStart = nYStart + nYStep )
2506 const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel);
2507 aNum.GetLevelVal()[ nLevel ] = rFmt.GetStart();
2508 sal_uInt16 nXStart( 0 );
2509 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2511 nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
2513 else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
2515 const long nTmpXStart( ( rFmt.GetIndentAt() +
2516 rFmt.GetFirstLineIndent() ) /
2517 nWidthRelation );
2518 if ( nTmpXStart < 0 )
2520 nXStart = 0;
2522 else
2524 nXStart = static_cast<sal_uInt16>(nTmpXStart);
2527 nXStart /= 2;
2528 nXStart += 2;
2529 sal_uInt16 nTextOffset = 2 * nXStep;
2530 if( SVX_NUM_BITMAP == (rFmt.GetNumberingType()&(~LINK_TOKEN)) )
2532 if(rFmt.IsShowSymbol())
2534 nTextOffset = lcl_DrawGraphic(pVDev, rFmt, nXStart, nYStart, nWidthRelation);
2535 nTextOffset = nTextOffset + nXStep;
2538 else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
2540 if(rFmt.IsShowSymbol())
2542 nTextOffset = lcl_DrawBullet(pVDev, rFmt, nXStart, nYStart, aStdFont.GetSize());
2543 nTextOffset = nTextOffset + nXStep;
2546 else
2548 Font aColorFont(aStdFont);
2549 Color aTmpBulletColor = rFmt.GetBulletColor();
2550 if(aTmpBulletColor.GetColor() == COL_AUTO)
2551 aTmpBulletColor = Color(aBackColor.IsDark() ? COL_WHITE : COL_BLACK);
2552 else if(aTmpBulletColor == aBackColor)
2553 aTmpBulletColor.Invert();
2554 aColorFont.SetColor(aTmpBulletColor);
2555 pVDev->SetFont(aColorFont);
2556 aNum.SetLevel( nLevel );
2557 if(pActNum->IsContinuousNumbering())
2558 aNum.GetLevelVal()[nLevel] = nPreNum;
2559 String aText(pActNum->MakeNumString( aNum ));
2560 pVDev->DrawText( Point(nXStart, nYStart), aText );
2561 pVDev->SetFont(aStdFont);
2562 nTextOffset = (sal_uInt16)pVDev->GetTextWidth(aText);
2563 nTextOffset = nTextOffset + nXStep;
2564 nPreNum++;
2566 if(pOutlineNames)
2568 //#i5153# outline numberings still use the style names as text
2569 pVDev->SetFont(aStdFont);
2570 sMsg = pOutlineNames[nLevel];
2571 pVDev->DrawText( Point(nXStart + nTextOffset, nYStart), sMsg );
2573 else
2575 //#i5153# the selected rectangle(s) should be black
2576 if( 0 != (nActLevel & (1<<nLevel)))
2578 pVDev->SetFillColor( aBlackColor );
2579 pVDev->SetLineColor( aBlackColor );
2581 else
2583 //#i5153# unselected levels are gray
2584 pVDev->SetFillColor( aLineColor );
2585 pVDev->SetLineColor( aLineColor );
2587 Rectangle aRect1(Point(nXStart + nTextOffset, nYStart + nTopOffset), Size(nWidth, nRectHeight));
2588 pVDev->DrawRect(aRect1);
2593 DrawOutDev( Point(0,0), aSize,
2594 Point(0,0), aSize,
2595 *pVDev );
2596 delete pVDev;
2600 //See uiconfig/swriter/ui/outlinepositionpage.ui for effectively a duplicate
2601 //dialog to this one, except with a different preview window impl.
2602 //TODO, determine if SwNumPositionTabPage and SvxNumPositionTabPage can be
2603 //merged
2604 SvxNumPositionTabPage::SvxNumPositionTabPage(Window* pParent,
2605 const SfxItemSet& rSet)
2606 : SfxTabPage(pParent, "NumberingPositionPage", "cui/ui/numberingpositionpage.ui", rSet)
2607 , pActNum(0)
2608 , pSaveNum(0)
2609 , nActNumLvl(USHRT_MAX)
2610 , nNumItemId(SID_ATTR_NUMBERING_RULE)
2611 , bModified(false)
2612 , bPreset(false)
2613 , bInInintControl(false)
2614 , bLabelAlignmentPosAndSpaceModeActive(false)
2616 SetExchangeSupport();
2618 get(m_pLevelLB, "levellb");
2619 get(m_pDistBorderFT, "indent");
2620 get(m_pDistBorderMF, "indentmf");
2621 get(m_pRelativeCB, "relative");
2622 get(m_pIndentFT, "numberingwidth");
2623 get(m_pIndentMF, "numberingwidthmf");
2624 get(m_pDistNumFT, "numdist");
2625 get(m_pDistNumMF, "numdistmf");
2626 get(m_pAlignFT, "numalign");
2627 get(m_pAlignLB, "numalignlb");
2629 get(m_pLabelFollowedByFT, "numfollowedby");
2630 get(m_pLabelFollowedByLB, "numfollowedbylb");
2631 get(m_pListtabFT, "at");
2632 get(m_pListtabMF, "atmf");
2633 get(m_pAlign2FT, "num2align");
2634 get(m_pAlign2LB, "num2alignlb");
2635 get(m_pAlignedAtFT, "alignedat");
2636 get(m_pAlignedAtMF, "alignedatmf");
2637 get(m_pIndentAtFT, "indentat");
2638 get(m_pIndentAtMF, "indentatmf");
2640 get(m_pStandardPB, "standard");
2641 get(m_pPreviewWIN, "preview");
2643 m_pPreviewWIN->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
2645 m_pRelativeCB->Check();
2646 m_pAlignLB->SetSelectHdl(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl));
2647 m_pAlign2LB->SetSelectHdl(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl));
2648 for ( sal_uInt16 i = 0; i < m_pAlignLB->GetEntryCount(); ++i )
2650 m_pAlign2LB->InsertEntry( m_pAlignLB->GetEntry( i ) );
2652 m_pAlign2LB->SetDropDownLineCount( m_pAlign2LB->GetEntryCount() );
2654 Link aLk = LINK(this, SvxNumPositionTabPage, DistanceHdl_Impl);
2656 m_pDistBorderMF->SetUpHdl(aLk);
2657 m_pDistBorderMF->SetDownHdl(aLk);
2658 m_pDistBorderMF->SetLoseFocusHdl(aLk);
2660 m_pDistNumMF->SetUpHdl(aLk);
2661 m_pDistNumMF->SetDownHdl(aLk);
2662 m_pDistNumMF->SetLoseFocusHdl(aLk);
2664 m_pIndentMF->SetUpHdl(aLk);
2665 m_pIndentMF->SetDownHdl(aLk);
2666 m_pIndentMF->SetLoseFocusHdl(aLk);
2668 m_pLabelFollowedByLB->SetDropDownLineCount( m_pLabelFollowedByLB->GetEntryCount() );
2669 m_pLabelFollowedByLB->SetSelectHdl( LINK(this, SvxNumPositionTabPage, LabelFollowedByHdl_Impl) );
2671 aLk = LINK(this, SvxNumPositionTabPage, ListtabPosHdl_Impl);
2672 m_pListtabMF->SetUpHdl(aLk);
2673 m_pListtabMF->SetDownHdl(aLk);
2674 m_pListtabMF->SetLoseFocusHdl(aLk);
2676 aLk = LINK(this, SvxNumPositionTabPage, AlignAtHdl_Impl);
2677 m_pAlignedAtMF->SetUpHdl(aLk);
2678 m_pAlignedAtMF->SetDownHdl(aLk);
2679 m_pAlignedAtMF->SetLoseFocusHdl(aLk);
2681 aLk = LINK(this, SvxNumPositionTabPage, IndentAtHdl_Impl);
2682 m_pIndentAtMF->SetUpHdl(aLk);
2683 m_pIndentAtMF->SetDownHdl(aLk);
2684 m_pIndentAtMF->SetLoseFocusHdl(aLk);
2686 m_pLevelLB->EnableMultiSelection(true);
2687 m_pLevelLB->SetSelectHdl(LINK(this, SvxNumPositionTabPage, LevelHdl_Impl));
2688 m_pRelativeCB->SetClickHdl(LINK(this, SvxNumPositionTabPage, RelativeHdl_Impl));
2689 m_pStandardPB->SetClickHdl(LINK(this, SvxNumPositionTabPage, StandardHdl_Impl));
2692 m_pRelativeCB->Check(bLastRelative);
2693 m_pPreviewWIN->SetPositionMode();
2694 eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
2697 SvxNumPositionTabPage::~SvxNumPositionTabPage()
2699 delete pActNum;
2700 delete pSaveNum;
2702 /*-------------------------------------------------------*/
2704 #if OSL_DEBUG_LEVEL > 1
2705 void lcl_PrintDebugOutput(FixedText& rFixed, const SvxNumberFormat& rNumFmt)
2707 #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
2709 OUString const sHash( " # " );
2710 if ( rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
2712 OUString sDebugText( OUString::valueOf( TWIP_TO_MM100(rNumFmt.GetAbsLSpace() ) ) );
2713 sDebugText += sHash;
2714 sDebugText += OUString::valueOf( TWIP_TO_MM100(rNumFmt.GetCharTextDistance() ) );
2715 sDebugText += sHash;
2716 sDebugText += OUString::valueOf( TWIP_TO_MM100(rNumFmt.GetFirstLineOffset() ) );
2717 rFixed.SetText(sDebugText);
2719 else if ( rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
2721 String sDebugText( OUString::valueOf( TWIP_TO_MM100(rNumFmt.GetListtabPos() ) ) );
2722 sDebugText += sHash;
2723 sDebugText += OUString::valueOf( TWIP_TO_MM100(rNumFmt.GetFirstLineIndent() ) );
2724 sDebugText += sHash;
2725 sDebugText += OUString::valueOf( TWIP_TO_MM100(rNumFmt.GetIndentAt() ) );
2726 rFixed.SetText(sDebugText);
2730 #endif
2732 void SvxNumPositionTabPage::InitControls()
2734 bInInintControl = sal_True;
2735 const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive &&
2736 m_pRelativeCB->IsEnabled() && m_pRelativeCB->IsChecked();
2737 const bool bSingleSelection = m_pLevelLB->GetSelectEntryCount() == 1 &&
2738 USHRT_MAX != nActNumLvl;
2740 m_pDistBorderMF->Enable( !bLabelAlignmentPosAndSpaceModeActive &&
2741 ( bSingleSelection || bRelative ) );
2742 m_pDistBorderFT->Enable( !bLabelAlignmentPosAndSpaceModeActive &&
2743 ( bSingleSelection || bRelative ) );
2745 bool bSetDistEmpty = false;
2746 bool bSameDistBorderNum = !bLabelAlignmentPosAndSpaceModeActive;
2747 bool bSameDist = !bLabelAlignmentPosAndSpaceModeActive;
2748 bool bSameIndent = !bLabelAlignmentPosAndSpaceModeActive;
2749 bool bSameAdjust = true;
2751 bool bSameLabelFollowedBy = bLabelAlignmentPosAndSpaceModeActive;
2752 bool bSameListtab = bLabelAlignmentPosAndSpaceModeActive;
2753 bool bSameAlignAt = bLabelAlignmentPosAndSpaceModeActive;
2754 bool bSameIndentAt = bLabelAlignmentPosAndSpaceModeActive;
2756 const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
2757 sal_uInt16 nMask = 1;
2758 sal_uInt16 nLvl = USHRT_MAX;
2759 long nFirstBorderTextRelative = -1;
2760 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2762 aNumFmtArr[i] = &pActNum->GetLevel(i);
2763 if(nActNumLvl & nMask)
2765 if(USHRT_MAX == nLvl)
2766 nLvl = i;
2768 if( i > nLvl)
2770 bSameAdjust &= aNumFmtArr[i]->GetNumAdjust() == aNumFmtArr[nLvl]->GetNumAdjust();
2771 if ( !bLabelAlignmentPosAndSpaceModeActive )
2773 if(bRelative)
2775 if(nFirstBorderTextRelative == -1)
2776 nFirstBorderTextRelative =
2777 (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
2778 aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
2779 else
2780 bSameDistBorderNum &= nFirstBorderTextRelative ==
2781 (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
2782 aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
2784 else
2785 bSameDistBorderNum &=
2786 aNumFmtArr[i]->GetAbsLSpace() - aNumFmtArr[i]->GetFirstLineOffset() ==
2787 aNumFmtArr[i - 1]->GetAbsLSpace() - aNumFmtArr[i - 1]->GetFirstLineOffset();
2789 bSameDist &= aNumFmtArr[i]->GetCharTextDistance() == aNumFmtArr[nLvl]->GetCharTextDistance();
2790 bSameIndent &= aNumFmtArr[i]->GetFirstLineOffset() == aNumFmtArr[nLvl]->GetFirstLineOffset();
2792 else
2794 bSameLabelFollowedBy &=
2795 aNumFmtArr[i]->GetLabelFollowedBy() == aNumFmtArr[nLvl]->GetLabelFollowedBy();
2796 bSameListtab &=
2797 aNumFmtArr[i]->GetListtabPos() == aNumFmtArr[nLvl]->GetListtabPos();
2798 bSameAlignAt &=
2799 ( ( aNumFmtArr[i]->GetIndentAt() + aNumFmtArr[i]->GetFirstLineIndent() )
2800 == ( aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent() ) );
2801 bSameIndentAt &=
2802 aNumFmtArr[i]->GetIndentAt() == aNumFmtArr[nLvl]->GetIndentAt();
2806 nMask <<= 1;
2809 if (SVX_MAX_NUM <= nLvl)
2811 OSL_ENSURE(false, "cannot happen.");
2812 return;
2815 if(bSameDistBorderNum)
2817 long nDistBorderNum;
2818 if(bRelative)
2820 nDistBorderNum = (long)aNumFmtArr[nLvl]->GetAbsLSpace()+ aNumFmtArr[nLvl]->GetFirstLineOffset();
2821 if(nLvl)
2822 nDistBorderNum -= (long)aNumFmtArr[nLvl - 1]->GetAbsLSpace()+ aNumFmtArr[nLvl - 1]->GetFirstLineOffset();
2824 else
2826 nDistBorderNum = (long)aNumFmtArr[nLvl]->GetAbsLSpace()+ aNumFmtArr[nLvl]->GetFirstLineOffset();
2828 SetMetricValue(*m_pDistBorderMF, nDistBorderNum, eCoreUnit);
2830 else
2831 bSetDistEmpty = true;
2833 const String aEmptyStr;
2834 if(bSameDist)
2835 SetMetricValue(*m_pDistNumMF, aNumFmtArr[nLvl]->GetCharTextDistance(), eCoreUnit);
2836 else
2837 m_pDistNumMF->SetText(aEmptyStr);
2838 if(bSameIndent)
2839 SetMetricValue(*m_pIndentMF, - aNumFmtArr[nLvl]->GetFirstLineOffset(), eCoreUnit);
2840 else
2841 m_pIndentMF->SetText(aEmptyStr);
2843 if(bSameAdjust)
2845 sal_uInt16 nPos = 1; // centered
2846 if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_LEFT)
2847 nPos = 0;
2848 else if(aNumFmtArr[nLvl]->GetNumAdjust() == SVX_ADJUST_RIGHT)
2849 nPos = 2;
2850 m_pAlignLB->SelectEntryPos(nPos);
2851 m_pAlign2LB->SelectEntryPos( nPos );
2853 else
2855 m_pAlignLB->SetNoSelection();
2856 m_pAlign2LB->SetNoSelection();
2859 if ( bSameLabelFollowedBy )
2861 sal_uInt16 nPos = 0; // LISTTAB
2862 if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::SPACE )
2864 nPos = 1;
2866 else if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING )
2868 nPos = 2;
2870 m_pLabelFollowedByLB->SelectEntryPos( nPos );
2872 else
2874 m_pLabelFollowedByLB->SetNoSelection();
2877 if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
2879 m_pListtabFT->Enable( true );
2880 m_pListtabMF->Enable( true );
2881 if ( bSameListtab )
2883 SetMetricValue(*m_pListtabMF, aNumFmtArr[nLvl]->GetListtabPos(), eCoreUnit);
2885 else
2887 m_pListtabMF->SetText(aEmptyStr);
2890 else
2892 m_pListtabFT->Enable( false );
2893 m_pListtabMF->Enable( false );
2894 m_pListtabMF->SetText(aEmptyStr);
2897 if ( bSameAlignAt )
2899 SetMetricValue(*m_pAlignedAtMF,
2900 aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent(),
2901 eCoreUnit);
2903 else
2905 m_pAlignedAtMF->SetText(aEmptyStr);
2908 if ( bSameIndentAt )
2910 SetMetricValue(*m_pIndentAtMF, aNumFmtArr[nLvl]->GetIndentAt(), eCoreUnit);
2912 else
2914 m_pIndentAtMF->SetText(aEmptyStr);
2917 if ( bSetDistEmpty )
2918 m_pDistBorderMF->SetText(aEmptyStr);
2920 bInInintControl = sal_False;
2923 void SvxNumPositionTabPage::ActivatePage(const SfxItemSet& rSet)
2925 const SfxPoolItem* pItem;
2926 sal_uInt16 nTmpNumLvl = USHRT_MAX;
2927 const SfxItemSet* pExampleSet = GetTabDialog()->GetExampleSet();
2928 if(pExampleSet)
2930 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, sal_False, &pItem))
2931 bPreset = ((const SfxBoolItem*)pItem)->GetValue();
2932 if(SFX_ITEM_SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pItem))
2933 nTmpNumLvl = ((const SfxUInt16Item*)pItem)->GetValue();
2935 if(SFX_ITEM_SET == rSet.GetItemState(nNumItemId, sal_False, &pItem))
2937 delete pSaveNum;
2938 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
2940 bModified = (!pActNum->Get( 0 ) || bPreset);
2941 if(*pSaveNum != *pActNum ||
2942 nActNumLvl != nTmpNumLvl )
2944 *pActNum = *pSaveNum;
2945 nActNumLvl = nTmpNumLvl;
2946 sal_uInt16 nMask = 1;
2947 m_pLevelLB->SetUpdateMode(false);
2948 m_pLevelLB->SetNoSelection();
2949 m_pLevelLB->SelectEntryPos( pActNum->GetLevelCount(), nActNumLvl == USHRT_MAX);
2950 if(nActNumLvl != USHRT_MAX)
2951 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2953 if(nActNumLvl & nMask)
2954 m_pLevelLB->SelectEntryPos( i, sal_True);
2955 nMask <<= 1 ;
2957 m_pRelativeCB->Enable(nActNumLvl != 1);
2958 m_pLevelLB->SetUpdateMode(sal_True);
2960 InitPosAndSpaceMode();
2961 ShowControlsDependingOnPosAndSpaceMode();
2963 InitControls();
2965 m_pPreviewWIN->SetLevel(nActNumLvl);
2966 m_pPreviewWIN->Invalidate();
2969 int SvxNumPositionTabPage::DeactivatePage(SfxItemSet *_pSet)
2971 if(_pSet)
2973 if(m_pDistBorderMF->IsEnabled())
2974 DistanceHdl_Impl(m_pDistBorderMF);
2975 DistanceHdl_Impl(m_pIndentMF);
2976 FillItemSet(*_pSet);
2978 return sal_True;
2981 sal_Bool SvxNumPositionTabPage::FillItemSet( SfxItemSet& rSet )
2983 rSet.Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
2985 if(bModified && pActNum)
2987 *pSaveNum = *pActNum;
2988 rSet.Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
2989 rSet.Put(SfxBoolItem(SID_PARAM_NUM_PRESET, sal_False));
2991 return bModified;
2994 void SvxNumPositionTabPage::Reset( const SfxItemSet& rSet )
2996 const SfxPoolItem* pItem;
2997 // in Draw the item exists as WhichId, in Writer only as SlotId
2998 SfxItemState eState = rSet.GetItemState(SID_ATTR_NUMBERING_RULE, sal_False, &pItem);
2999 if(eState != SFX_ITEM_SET)
3001 nNumItemId = rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
3002 eState = rSet.GetItemState(nNumItemId, sal_False, &pItem);
3004 if( eState != SFX_ITEM_SET )
3006 pItem = &static_cast< const SvxNumBulletItem& >( rSet.Get( nNumItemId, sal_True ) );
3007 eState = SFX_ITEM_SET;
3011 DBG_ASSERT(eState == SFX_ITEM_SET, "kein Item gefunden!");
3012 delete pSaveNum;
3013 pSaveNum = new SvxNumRule(*((SvxNumBulletItem*)pItem)->GetNumRule());
3015 // insert levels
3016 if(!m_pLevelLB->GetEntryCount())
3018 for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
3019 m_pLevelLB->InsertEntry( OUString::number(i) );
3020 if(pSaveNum->GetLevelCount() > 1)
3022 OUString sEntry( "1 - " );
3023 sEntry += OUString::valueOf( static_cast<sal_Int32>(pSaveNum->GetLevelCount()) );
3024 m_pLevelLB->InsertEntry(sEntry);
3025 m_pLevelLB->SelectEntry(sEntry);
3027 else
3028 m_pLevelLB->SelectEntryPos(0);
3030 else
3031 m_pLevelLB->SelectEntryPos(m_pLevelLB->GetEntryCount() - 1);
3032 sal_uInt16 nMask = 1;
3033 m_pLevelLB->SetUpdateMode(sal_False);
3034 m_pLevelLB->SetNoSelection();
3035 if(nActNumLvl == USHRT_MAX)
3037 m_pLevelLB->SelectEntryPos( pSaveNum->GetLevelCount(), sal_True);
3039 else
3041 for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
3043 if(nActNumLvl & nMask)
3044 m_pLevelLB->SelectEntryPos( i, sal_True);
3045 nMask <<= 1;
3048 m_pLevelLB->SetUpdateMode(sal_True);
3050 if(!pActNum)
3051 pActNum = new SvxNumRule(*pSaveNum);
3052 else if(*pSaveNum != *pActNum)
3053 *pActNum = *pSaveNum;
3054 m_pPreviewWIN->SetNumRule(pActNum);
3056 InitPosAndSpaceMode();
3057 ShowControlsDependingOnPosAndSpaceMode();
3059 InitControls();
3060 bModified = sal_False;
3063 void SvxNumPositionTabPage::InitPosAndSpaceMode()
3065 if ( pActNum == 0 )
3067 DBG_ASSERT( false,
3068 "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
3069 return;
3072 SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode =
3073 SvxNumberFormat::LABEL_ALIGNMENT;
3074 sal_uInt16 nMask = 1;
3075 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3077 if(nActNumLvl & nMask)
3079 SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3080 ePosAndSpaceMode = aNumFmt.GetPositionAndSpaceMode();
3081 if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
3083 break;
3086 nMask <<= 1;
3089 bLabelAlignmentPosAndSpaceModeActive =
3090 ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT;
3093 void SvxNumPositionTabPage::ShowControlsDependingOnPosAndSpaceMode()
3095 m_pDistBorderFT->Show( !bLabelAlignmentPosAndSpaceModeActive );
3096 m_pDistBorderMF->Show( !bLabelAlignmentPosAndSpaceModeActive );
3097 m_pRelativeCB->Show( !bLabelAlignmentPosAndSpaceModeActive );
3098 m_pIndentFT->Show( !bLabelAlignmentPosAndSpaceModeActive );
3099 m_pIndentMF->Show( !bLabelAlignmentPosAndSpaceModeActive );
3100 m_pDistNumFT->Show( !bLabelAlignmentPosAndSpaceModeActive &&
3101 pActNum->IsFeatureSupported(NUM_CONTINUOUS) );
3102 m_pDistNumMF->Show( !bLabelAlignmentPosAndSpaceModeActive &&
3103 pActNum->IsFeatureSupported(NUM_CONTINUOUS));
3104 m_pAlignFT->Show( !bLabelAlignmentPosAndSpaceModeActive );
3105 m_pAlignLB->Show( !bLabelAlignmentPosAndSpaceModeActive );
3107 m_pLabelFollowedByFT->Show( bLabelAlignmentPosAndSpaceModeActive );
3108 m_pLabelFollowedByLB->Show( bLabelAlignmentPosAndSpaceModeActive );
3109 m_pListtabFT->Show( bLabelAlignmentPosAndSpaceModeActive );
3110 m_pListtabMF->Show( bLabelAlignmentPosAndSpaceModeActive );
3111 m_pAlign2FT->Show( bLabelAlignmentPosAndSpaceModeActive );
3112 m_pAlign2LB->Show( bLabelAlignmentPosAndSpaceModeActive );
3113 m_pAlignedAtFT->Show( bLabelAlignmentPosAndSpaceModeActive );
3114 m_pAlignedAtMF->Show( bLabelAlignmentPosAndSpaceModeActive );
3115 m_pIndentAtFT->Show( bLabelAlignmentPosAndSpaceModeActive );
3116 m_pIndentAtMF->Show( bLabelAlignmentPosAndSpaceModeActive );
3119 SfxTabPage* SvxNumPositionTabPage::Create( Window* pParent,
3120 const SfxItemSet& rAttrSet)
3122 return new SvxNumPositionTabPage(pParent, rAttrSet);
3125 void SvxNumPositionTabPage::SetMetric(FieldUnit eMetric)
3127 if(eMetric == FUNIT_MM)
3129 m_pDistBorderMF->SetDecimalDigits(1);
3130 m_pDistNumMF->SetDecimalDigits(1);
3131 m_pIndentMF->SetDecimalDigits(1);
3132 m_pListtabMF->SetDecimalDigits(1);
3133 m_pAlignedAtMF->SetDecimalDigits(1);
3134 m_pIndentAtMF->SetDecimalDigits(1);
3136 m_pDistBorderMF->SetUnit( eMetric );
3137 m_pDistNumMF->SetUnit( eMetric );
3138 m_pIndentMF->SetUnit( eMetric );
3139 m_pListtabMF->SetUnit( eMetric );
3140 m_pAlignedAtMF->SetUnit( eMetric );
3141 m_pIndentAtMF->SetUnit( eMetric );
3144 IMPL_LINK_NOARG(SvxNumPositionTabPage, EditModifyHdl_Impl)
3146 sal_uInt16 nMask = 1;
3147 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3149 if(nActNumLvl & nMask)
3151 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
3153 const sal_uInt16 nPos = m_pAlignLB->IsVisible()
3154 ? m_pAlignLB->GetSelectEntryPos()
3155 : m_pAlign2LB->GetSelectEntryPos();
3156 SvxAdjust eAdjust = SVX_ADJUST_CENTER;
3157 if(nPos == 0)
3158 eAdjust = SVX_ADJUST_LEFT;
3159 else if(nPos == 2)
3160 eAdjust = SVX_ADJUST_RIGHT;
3161 aNumFmt.SetNumAdjust( eAdjust );
3162 pActNum->SetLevel(i, aNumFmt);
3164 nMask <<= 1;
3166 SetModified();
3167 return 0;
3170 IMPL_LINK( SvxNumPositionTabPage, LevelHdl_Impl, ListBox *, pBox )
3172 sal_uInt16 nSaveNumLvl = nActNumLvl;
3173 nActNumLvl = 0;
3174 if(pBox->IsEntryPosSelected( pActNum->GetLevelCount() ) &&
3175 (pBox->GetSelectEntryCount() == 1 || nSaveNumLvl != 0xffff))
3177 nActNumLvl = 0xFFFF;
3178 pBox->SetUpdateMode(sal_False);
3179 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
3180 pBox->SelectEntryPos( i, sal_False );
3181 pBox->SetUpdateMode(sal_True);
3183 else if(pBox->GetSelectEntryCount())
3185 sal_uInt16 nMask = 1;
3186 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
3188 if(pBox->IsEntryPosSelected( i ))
3189 nActNumLvl |= nMask;
3190 nMask <<= 1;
3192 pBox->SelectEntryPos( pActNum->GetLevelCount(), sal_False );
3194 else
3196 nActNumLvl = nSaveNumLvl;
3197 sal_uInt16 nMask = 1;
3198 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
3200 if(nActNumLvl & nMask)
3202 pBox->SelectEntryPos(i);
3203 break;
3205 nMask <<=1;
3208 m_pRelativeCB->Enable(nActNumLvl != 1);
3209 SetModified();
3210 InitPosAndSpaceMode();
3211 ShowControlsDependingOnPosAndSpaceMode();
3212 InitControls();
3213 return 0;
3216 IMPL_LINK( SvxNumPositionTabPage, DistanceHdl_Impl, MetricField *, pFld )
3218 if(bInInintControl)
3219 return 0;
3220 long nValue = GetCoreValue(*pFld, eCoreUnit);
3221 sal_uInt16 nMask = 1;
3222 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3224 if(nActNumLvl & nMask)
3226 SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) );
3227 if (pFld == m_pDistBorderMF)
3230 if(m_pRelativeCB->IsChecked())
3232 if(0 == i)
3234 long nTmp = aNumFmt.GetFirstLineOffset();
3235 aNumFmt.SetAbsLSpace( sal_uInt16(nValue - nTmp));
3237 else
3239 long nTmp = pActNum->GetLevel( i - 1 ).GetAbsLSpace() +
3240 pActNum->GetLevel( i - 1 ).GetFirstLineOffset() -
3241 pActNum->GetLevel( i ).GetFirstLineOffset();
3243 aNumFmt.SetAbsLSpace( sal_uInt16(nValue + nTmp));
3246 else
3248 aNumFmt.SetAbsLSpace( (short)nValue - aNumFmt.GetFirstLineOffset());
3251 else if (pFld == m_pDistNumMF)
3253 aNumFmt.SetCharTextDistance( (short)nValue );
3255 else if (pFld == m_pIndentMF)
3257 // together with the FirstLineOffset the AbsLSpace must be changed, too
3258 long nDiff = nValue + aNumFmt.GetFirstLineOffset();
3259 long nAbsLSpace = aNumFmt.GetAbsLSpace();
3260 aNumFmt.SetAbsLSpace(sal_uInt16(nAbsLSpace + nDiff));
3261 aNumFmt.SetFirstLineOffset( -(short)nValue );
3264 pActNum->SetLevel( i, aNumFmt );
3266 nMask <<= 1;
3269 SetModified();
3270 if(!m_pDistBorderMF->IsEnabled())
3272 String aEmptyStr;
3273 m_pDistBorderMF->SetText(aEmptyStr);
3276 return 0;
3279 IMPL_LINK( SvxNumPositionTabPage, RelativeHdl_Impl, CheckBox *, pBox )
3281 sal_Bool bOn = pBox->IsChecked();
3282 sal_Bool bSingleSelection = m_pLevelLB->GetSelectEntryCount() == 1 && USHRT_MAX != nActNumLvl;
3283 sal_Bool bSetValue = sal_False;
3284 long nValue = 0;
3285 if(bOn || bSingleSelection)
3287 sal_uInt16 nMask = 1;
3288 sal_Bool bFirst = sal_True;
3289 bSetValue = sal_True;
3290 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3292 if(nActNumLvl & nMask)
3294 const SvxNumberFormat &rNumFmt = pActNum->GetLevel(i);
3295 if(bFirst)
3297 nValue = rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset();
3298 if(bOn && i)
3299 nValue -= (pActNum->GetLevel(i - 1).GetAbsLSpace() + pActNum->GetLevel(i - 1).GetFirstLineOffset());
3301 else
3302 bSetValue = nValue ==
3303 (rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset()) -
3304 (pActNum->GetLevel(i - 1).GetAbsLSpace() + pActNum->GetLevel(i - 1).GetFirstLineOffset());
3305 bFirst = sal_False;
3307 nMask <<= 1;
3311 String aEmptyStr;
3312 if(bSetValue)
3313 SetMetricValue(*m_pDistBorderMF, nValue, eCoreUnit);
3314 else
3315 m_pDistBorderMF->SetText(aEmptyStr);
3316 m_pDistBorderMF->Enable(bOn || bSingleSelection);
3317 m_pDistBorderFT->Enable(bOn || bSingleSelection);
3318 bLastRelative = bOn;
3319 return 0;
3322 IMPL_LINK_NOARG(SvxNumPositionTabPage, LabelFollowedByHdl_Impl)
3324 // determine value to be set at the chosen list levels
3325 SvxNumberFormat::LabelFollowedBy eLabelFollowedBy = SvxNumberFormat::LISTTAB;
3327 const sal_uInt16 nPos = m_pLabelFollowedByLB->GetSelectEntryPos();
3328 if ( nPos == 1 )
3330 eLabelFollowedBy = SvxNumberFormat::SPACE;
3332 else if ( nPos == 2 )
3334 eLabelFollowedBy = SvxNumberFormat::NOTHING;
3338 // set value at the chosen list levels
3339 bool bSameListtabPos = true;
3340 sal_uInt16 nFirstLvl = USHRT_MAX;
3341 sal_uInt16 nMask = 1;
3342 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3344 if ( nActNumLvl & nMask )
3346 SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3347 aNumFmt.SetLabelFollowedBy( eLabelFollowedBy );
3348 pActNum->SetLevel( i, aNumFmt );
3350 if ( nFirstLvl == USHRT_MAX )
3352 nFirstLvl = i;
3354 else
3356 bSameListtabPos &= aNumFmt.GetListtabPos() ==
3357 pActNum->GetLevel( nFirstLvl ).GetListtabPos();
3360 nMask <<= 1;
3363 // enable/disable metric field for list tab stop position depending on
3364 // selected item following the list label.
3365 m_pListtabFT->Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
3366 m_pListtabMF->Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
3367 if ( bSameListtabPos && eLabelFollowedBy == SvxNumberFormat::LISTTAB )
3369 SetMetricValue(*m_pListtabMF, pActNum->GetLevel( nFirstLvl ).GetListtabPos(), eCoreUnit);
3371 else
3373 m_pListtabMF->SetText( String() );
3376 SetModified();
3378 return 0;
3381 IMPL_LINK( SvxNumPositionTabPage, ListtabPosHdl_Impl, MetricField*, pFld )
3383 // determine value to be set at the chosen list levels
3384 const long nValue = GetCoreValue( *pFld, eCoreUnit );
3386 // set value at the chosen list levels
3387 sal_uInt16 nMask = 1;
3388 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3390 if ( nActNumLvl & nMask )
3392 SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3393 aNumFmt.SetListtabPos( nValue );
3394 pActNum->SetLevel( i, aNumFmt );
3396 nMask <<= 1;
3399 SetModified();
3401 return 0;
3404 IMPL_LINK( SvxNumPositionTabPage, AlignAtHdl_Impl, MetricField*, pFld )
3406 // determine value to be set at the chosen list levels
3407 const long nValue = GetCoreValue( *pFld, eCoreUnit );
3409 // set value at the chosen list levels
3410 sal_uInt16 nMask = 1;
3411 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3413 if ( nActNumLvl & nMask )
3415 SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3416 const long nFirstLineIndent = nValue - aNumFmt.GetIndentAt();
3417 aNumFmt.SetFirstLineIndent( nFirstLineIndent );
3418 pActNum->SetLevel( i, aNumFmt );
3420 nMask <<= 1;
3423 SetModified();
3425 return 0;
3428 IMPL_LINK( SvxNumPositionTabPage, IndentAtHdl_Impl, MetricField*, pFld )
3430 // determine value to be set at the chosen list levels
3431 const long nValue = GetCoreValue( *pFld, eCoreUnit );
3433 // set value at the chosen list levels
3434 sal_uInt16 nMask = 1;
3435 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3437 if ( nActNumLvl & nMask )
3439 SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3440 const long nAlignedAt = aNumFmt.GetIndentAt() +
3441 aNumFmt.GetFirstLineIndent();
3442 aNumFmt.SetIndentAt( nValue );
3443 const long nNewFirstLineIndent = nAlignedAt - nValue;
3444 aNumFmt.SetFirstLineIndent( nNewFirstLineIndent );
3445 pActNum->SetLevel( i, aNumFmt );
3447 nMask <<= 1;
3450 SetModified();
3452 return 0;
3455 IMPL_LINK_NOARG(SvxNumPositionTabPage, StandardHdl_Impl)
3457 sal_uInt16 nMask = 1;
3458 SvxNumRule aTmpNumRule( pActNum->GetFeatureFlags(),
3459 pActNum->GetLevelCount(),
3460 pActNum->IsContinuousNumbering(),
3461 SVX_RULETYPE_NUMBERING,
3462 pActNum->GetLevel( 0 ).GetPositionAndSpaceMode() );
3463 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3465 if(nActNumLvl & nMask)
3467 SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) );
3468 SvxNumberFormat aTempFmt(aTmpNumRule.GetLevel( i ));
3469 aNumFmt.SetPositionAndSpaceMode( aTempFmt.GetPositionAndSpaceMode() );
3470 if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
3472 aNumFmt.SetAbsLSpace( aTempFmt.GetAbsLSpace() );
3473 aNumFmt.SetCharTextDistance( aTempFmt.GetCharTextDistance() );
3474 aNumFmt.SetFirstLineOffset( aTempFmt.GetFirstLineOffset() );
3476 else if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
3478 aNumFmt.SetNumAdjust( aTempFmt.GetNumAdjust() );
3479 aNumFmt.SetLabelFollowedBy( aTempFmt.GetLabelFollowedBy() );
3480 aNumFmt.SetListtabPos( aTempFmt.GetListtabPos() );
3481 aNumFmt.SetFirstLineIndent( aTempFmt.GetFirstLineIndent() );
3482 aNumFmt.SetIndentAt( aTempFmt.GetIndentAt() );
3485 pActNum->SetLevel( i, aNumFmt );
3487 nMask <<= 1;
3490 InitControls();
3491 SetModified();
3492 return 0;
3495 void SvxNumPositionTabPage::SetModified(sal_Bool bRepaint)
3497 bModified = sal_True;
3498 if(bRepaint)
3500 m_pPreviewWIN->SetLevel(nActNumLvl);
3501 m_pPreviewWIN->Invalidate();
3505 void SvxNumOptionsTabPage::SetModified(sal_Bool bRepaint)
3507 bModified = sal_True;
3508 if(bRepaint)
3510 m_pPreviewWIN->SetLevel(nActNumLvl);
3511 m_pPreviewWIN->Invalidate();
3515 void SvxNumOptionsTabPage::PageCreated(SfxAllItemSet aSet)
3517 SFX_ITEMSET_ARG (&aSet,pListItem,SfxStringListItem,SID_CHAR_FMT_LIST_BOX,sal_False);
3518 SFX_ITEMSET_ARG (&aSet,pNumCharFmt,SfxStringItem,SID_NUM_CHAR_FMT,sal_False);
3519 SFX_ITEMSET_ARG (&aSet,pBulletCharFmt,SfxStringItem,SID_BULLET_CHAR_FMT,sal_False);
3520 SFX_ITEMSET_ARG (&aSet,pMetricItem,SfxAllEnumItem,SID_METRIC_ITEM,sal_False);
3522 if (pNumCharFmt &&pBulletCharFmt)
3523 SetCharFmts( pNumCharFmt->GetValue(),pBulletCharFmt->GetValue());
3525 if (pListItem)
3527 ListBox& myCharFmtLB = GetCharFmtListBox();
3528 const std::vector<String> &aList = (pListItem)->GetList();
3529 sal_uInt32 nCount = aList.size();;
3530 for(sal_uInt32 i = 0; i < nCount; i++)
3531 myCharFmtLB.InsertEntry(aList[i]);
3533 if (pMetricItem)
3534 SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
3537 void SvxNumPositionTabPage::PageCreated(SfxAllItemSet aSet)
3539 SFX_ITEMSET_ARG (&aSet,pMetricItem,SfxAllEnumItem,SID_METRIC_ITEM,sal_False);
3541 if (pMetricItem)
3542 SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
3545 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */