Bump version to 6.4.7.2.M8
[LibreOffice.git] / cui / source / tabpages / numpages.cxx
blob5692dd73aefe38c3f362966bcad89a1c6638badc
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>
23 #include <numpages.hxx>
24 #include <dialmgr.hxx>
25 #include <tools/mapunit.hxx>
26 #include <i18nlangtag/languagetag.hxx>
27 #include <i18nlangtag/mslangid.hxx>
28 #include <editeng/numitem.hxx>
29 #include <svl/eitem.hxx>
30 #include <vcl/svapp.hxx>
31 #include <svx/colorbox.hxx>
32 #include <svx/strarray.hxx>
33 #include <svx/gallery.hxx>
34 #include <editeng/brushitem.hxx>
35 #include <svl/intitem.hxx>
36 #include <sfx2/objsh.hxx>
37 #include <vcl/graph.hxx>
38 #include <vcl/settings.hxx>
39 #include <cui/cuicharmap.hxx>
40 #include <editeng/flstitem.hxx>
41 #include <svx/numvset.hxx>
42 #include <sfx2/htmlmode.hxx>
43 #include <unotools/pathoptions.hxx>
44 #include <svtools/ctrltool.hxx>
45 #include <svtools/unitconv.hxx>
46 #include <com/sun/star/style/NumberingType.hpp>
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #include <com/sun/star/container/XIndexAccess.hpp>
49 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
50 #include <com/sun/star/text/XNumberingFormatter.hpp>
51 #include <com/sun/star/beans/PropertyValue.hpp>
52 #include <comphelper/processfactory.hxx>
53 #include <svx/svxids.hrc>
55 #include <algorithm>
56 #include <memory>
57 #include <vector>
58 #include <sfx2/opengrf.hxx>
60 #include <strings.hrc>
61 #include <svl/aeitem.hxx>
62 #include <svl/stritem.hxx>
63 #include <svl/slstitm.hxx>
64 #include <sfx2/filedlghelper.hxx>
65 #include <unotools/ucbstreamhelper.hxx>
66 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
67 #include <sal/log.hxx>
68 #include <vcl/cvtgrf.hxx>
69 #include <vcl/graphicfilter.hxx>
70 #include <svx/SvxNumOptionsTabPageHelper.hxx>
71 #include <tools/urlobj.hxx>
72 #include <osl/diagnose.h>
74 using namespace css;
75 using namespace css::uno;
76 using namespace css::beans;
77 using namespace css::lang;
78 using namespace css::i18n;
79 using namespace css::text;
80 using namespace css::container;
81 using namespace css::style;
83 #define SHOW_NUMBERING 0
84 #define SHOW_BULLET 1
85 #define SHOW_BITMAP 2
87 #define MAX_BMP_WIDTH 16
88 #define MAX_BMP_HEIGHT 16
89 #define SEARCHPATH_DELIMITER u';'
90 #define SEARCHFILENAME_DELIMITER u'/'
92 static bool bLastRelative = false;
94 static SvxNumSettings_Impl* lcl_CreateNumSettingsPtr(const Sequence<PropertyValue>& rLevelProps)
96 const PropertyValue* pValues = rLevelProps.getConstArray();
97 SvxNumSettings_Impl* pNew = new SvxNumSettings_Impl;
98 for(sal_Int32 j = 0; j < rLevelProps.getLength(); j++)
100 if ( pValues[j].Name == "NumberingType" )
102 sal_Int16 nTmp;
103 if (pValues[j].Value >>= nTmp)
104 pNew->nNumberType = static_cast<SvxNumType>(nTmp);
106 else if ( pValues[j].Name == "Prefix" )
107 pValues[j].Value >>= pNew->sPrefix;
108 else if ( pValues[j].Name == "Suffix" )
109 pValues[j].Value >>= pNew->sSuffix;
110 else if ( pValues[j].Name == "ParentNumbering" )
111 pValues[j].Value >>= pNew->nParentNumbering;
112 else if ( pValues[j].Name == "BulletChar" )
113 pValues[j].Value >>= pNew->sBulletChar;
114 else if ( pValues[j].Name == "BulletFontName" )
115 pValues[j].Value >>= pNew->sBulletFont;
117 return pNew;
120 // the selection of bullets from the OpenSymbol
121 static const sal_Unicode aBulletTypes[] =
123 0x2022,
124 0x25cf,
125 0xe00c,
126 0xe00a,
127 0x2794,
128 0x27a2,
129 0x2717,
130 0x2714
133 // Is one of the masked formats set?
134 static bool lcl_IsNumFmtSet(SvxNumRule const * pNum, sal_uInt16 nLevelMask)
136 bool bRet = false;
137 sal_uInt16 nMask = 1;
138 for( sal_uInt16 i = 0; i < SVX_MAX_NUM && !bRet; i++ )
140 if(nLevelMask & nMask)
141 bRet |= nullptr != pNum->Get( i );
142 nMask <<= 1 ;
144 return bRet;
147 static const vcl::Font& lcl_GetDefaultBulletFont()
149 static vcl::Font aDefBulletFont = [&]()
151 vcl::Font tmp("OpenSymbol", "", Size(0, 14));
152 tmp.SetCharSet( RTL_TEXTENCODING_SYMBOL );
153 tmp.SetFamily( FAMILY_DONTKNOW );
154 tmp.SetPitch( PITCH_DONTKNOW );
155 tmp.SetWeight( WEIGHT_DONTKNOW );
156 tmp.SetTransparent( true );
157 return tmp;
158 }();
159 return aDefBulletFont;
162 SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
163 : SfxTabPage(pPage, pController, "cui/ui/picknumberingpage.ui", "PickNumberingPage", &rSet)
164 , nActNumLvl(SAL_MAX_UINT16)
165 , bModified(false)
166 , bPreset(false)
167 , nNumItemId(SID_ATTR_NUMBERING_RULE)
168 , m_xExamplesVS(new NumValueSet(nullptr))
169 , m_xExamplesVSWin(new weld::CustomWeld(*m_xBuilder, "valueset", *m_xExamplesVS))
171 SetExchangeSupport();
172 m_xExamplesVS->init(NumberingPageType::SINGLENUM);
173 m_xExamplesVS->SetSelectHdl(LINK(this, SvxSingleNumPickTabPage, NumSelectHdl_Impl));
174 m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxSingleNumPickTabPage, DoubleClickHdl_Impl));
176 Reference<XDefaultNumberingProvider> xDefNum = SvxNumOptionsTabPageHelper::GetNumberingProvider();
177 if(xDefNum.is())
179 Sequence< Sequence< PropertyValue > > aNumberings;
180 const Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale();
183 aNumberings =
184 xDefNum->getDefaultContinuousNumberingLevels( rLocale );
187 sal_Int32 nLength = std::min<sal_Int32>(aNumberings.getLength(), NUM_VALUSET_COUNT);
189 const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray();
190 for(sal_Int32 i = 0; i < nLength; i++)
192 SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(pValuesArr[i]);
193 aNumSettingsArr.push_back(std::unique_ptr<SvxNumSettings_Impl>(pNew));
196 catch(const Exception&)
199 Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
200 m_xExamplesVS->SetNumberingSettings(aNumberings, xFormat, rLocale);
204 SvxSingleNumPickTabPage::~SvxSingleNumPickTabPage()
206 m_xExamplesVSWin.reset();
207 m_xExamplesVS.reset();
210 std::unique_ptr<SfxTabPage> SvxSingleNumPickTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
211 const SfxItemSet* rAttrSet)
213 return std::make_unique<SvxSingleNumPickTabPage>(pPage, pController, *rAttrSet);
216 bool SvxSingleNumPickTabPage::FillItemSet( SfxItemSet* rSet )
218 if( (bPreset || bModified) && pSaveNum)
220 *pSaveNum = *pActNum;
221 rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ));
222 rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
225 return bModified;
228 void SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
230 const SfxPoolItem* pItem;
231 bPreset = false;
232 bool bIsPreset = false;
233 const SfxItemSet* pExampleSet = GetDialogExampleSet();
234 if(pExampleSet)
236 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
237 bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue();
238 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
239 nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
241 if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
243 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
245 if(pActNum && *pSaveNum != *pActNum)
247 *pActNum = *pSaveNum;
248 m_xExamplesVS->SetNoSelection();
251 if(pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset))
253 m_xExamplesVS->SelectItem(1);
254 NumSelectHdl_Impl(m_xExamplesVS.get());
255 bPreset = true;
257 bPreset |= bIsPreset;
259 bModified = false;
262 DeactivateRC SvxSingleNumPickTabPage::DeactivatePage(SfxItemSet *_pSet)
264 if(_pSet)
265 FillItemSet(_pSet);
266 return DeactivateRC::LeavePage;
269 void SvxSingleNumPickTabPage::Reset( const SfxItemSet* rSet )
271 const SfxPoolItem* pItem;
273 // in Draw the item exists as WhichId, in Writer only as SlotId
274 SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
275 if(eState != SfxItemState::SET)
277 nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
278 eState = rSet->GetItemState(nNumItemId, false, &pItem);
280 if( eState != SfxItemState::SET )
282 pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
283 eState = SfxItemState::SET;
286 DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
287 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
289 if(!pActNum)
290 pActNum.reset( new SvxNumRule(*pSaveNum) );
291 else if(*pSaveNum != *pActNum)
292 *pActNum = *pSaveNum;
295 IMPL_LINK_NOARG(SvxSingleNumPickTabPage, NumSelectHdl_Impl, SvtValueSet*, void)
297 if(pActNum)
299 bPreset = false;
300 bModified = true;
301 sal_uInt16 nIdx = m_xExamplesVS->GetSelectedItemId() - 1;
302 DBG_ASSERT(aNumSettingsArr.size() > nIdx, "wrong index");
303 if(aNumSettingsArr.size() <= nIdx)
304 return;
305 SvxNumSettings_Impl* _pSet = aNumSettingsArr[nIdx].get();
306 SvxNumType eNewType = _pSet->nNumberType;
307 const sal_Unicode cLocalPrefix = !_pSet->sPrefix.isEmpty() ? _pSet->sPrefix[0] : 0;
308 const sal_Unicode cLocalSuffix = !_pSet->sSuffix.isEmpty() ? _pSet->sSuffix[0] : 0;
310 sal_uInt16 nMask = 1;
311 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
313 if(nActNumLvl & nMask)
315 SvxNumberFormat aFmt(pActNum->GetLevel(i));
316 aFmt.SetNumberingType(eNewType);
317 if(cLocalPrefix == ' ')
318 aFmt.SetPrefix( "" );
319 else
320 aFmt.SetPrefix(_pSet->sPrefix);
321 if(cLocalSuffix == ' ')
322 aFmt.SetSuffix( "" );
323 else
324 aFmt.SetSuffix(_pSet->sSuffix);
325 aFmt.SetCharFormatName("");
326 aFmt.SetBulletRelSize(100);
327 pActNum->SetLevel(i, aFmt);
329 nMask <<= 1;
334 IMPL_LINK_NOARG(SvxSingleNumPickTabPage, DoubleClickHdl_Impl, SvtValueSet*, void)
336 NumSelectHdl_Impl(m_xExamplesVS.get());
337 weld::Button& rOk = GetDialogController()->GetOKButton();
338 rOk.clicked();
341 SvxBulletPickTabPage::SvxBulletPickTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
342 : SfxTabPage(pPage, pController, "cui/ui/pickbulletpage.ui", "PickBulletPage", &rSet)
343 , nActNumLvl(SAL_MAX_UINT16)
344 , bModified(false)
345 , bPreset(false)
346 , nNumItemId(SID_ATTR_NUMBERING_RULE)
347 , m_xExamplesVS(new NumValueSet(nullptr))
348 , m_xExamplesVSWin(new weld::CustomWeld(*m_xBuilder, "valueset", *m_xExamplesVS))
350 SetExchangeSupport();
351 m_xExamplesVS->init(NumberingPageType::BULLET);
352 m_xExamplesVS->SetSelectHdl(LINK(this, SvxBulletPickTabPage, NumSelectHdl_Impl));
353 m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxBulletPickTabPage, DoubleClickHdl_Impl));
356 SvxBulletPickTabPage::~SvxBulletPickTabPage()
358 m_xExamplesVSWin.reset();
359 m_xExamplesVS.reset();
362 std::unique_ptr<SfxTabPage> SvxBulletPickTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
363 const SfxItemSet* rAttrSet)
365 return std::make_unique<SvxBulletPickTabPage>(pPage, pController, *rAttrSet);
368 bool SvxBulletPickTabPage::FillItemSet( SfxItemSet* rSet )
370 if( (bPreset || bModified) && pActNum)
372 *pSaveNum = *pActNum;
373 rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ));
374 rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
376 return bModified;
379 void SvxBulletPickTabPage::ActivatePage(const SfxItemSet& rSet)
381 const SfxPoolItem* pItem;
382 bPreset = false;
383 bool bIsPreset = false;
384 const SfxItemSet* pExampleSet = GetDialogExampleSet();
385 if(pExampleSet)
387 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
388 bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue();
389 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
390 nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
392 if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
394 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
396 if(pActNum && *pSaveNum != *pActNum)
398 *pActNum = *pSaveNum;
399 m_xExamplesVS->SetNoSelection();
402 if(pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset))
404 m_xExamplesVS->SelectItem(1);
405 NumSelectHdl_Impl(m_xExamplesVS.get());
406 bPreset = true;
408 bPreset |= bIsPreset;
409 bModified = false;
412 DeactivateRC SvxBulletPickTabPage::DeactivatePage(SfxItemSet *_pSet)
414 if(_pSet)
415 FillItemSet(_pSet);
416 return DeactivateRC::LeavePage;
419 void SvxBulletPickTabPage::Reset( const SfxItemSet* rSet )
421 const SfxPoolItem* pItem;
422 // in Draw the item exists as WhichId, in Writer only as SlotId
423 SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
424 if(eState != SfxItemState::SET)
426 nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
427 eState = rSet->GetItemState(nNumItemId, false, &pItem);
429 if( eState != SfxItemState::SET )
431 pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
432 eState = SfxItemState::SET;
436 DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
437 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
439 if(!pActNum)
440 pActNum.reset( new SvxNumRule(*pSaveNum) );
441 else if(*pSaveNum != *pActNum)
442 *pActNum = *pSaveNum;
445 IMPL_LINK_NOARG(SvxBulletPickTabPage, NumSelectHdl_Impl, SvtValueSet*, void)
447 if(pActNum)
449 bPreset = false;
450 bModified = true;
451 sal_Unicode cChar = aBulletTypes[m_xExamplesVS->GetSelectedItemId() - 1];
452 const vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont();
454 sal_uInt16 nMask = 1;
455 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
457 if(nActNumLvl & nMask)
459 SvxNumberFormat aFmt(pActNum->GetLevel(i));
460 aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
461 // #i93908# clear suffix for bullet lists
462 aFmt.SetPrefix( OUString() );
463 aFmt.SetSuffix( OUString() );
464 aFmt.SetBulletFont(&rActBulletFont);
465 aFmt.SetBulletChar(cChar );
466 aFmt.SetCharFormatName(sBulletCharFormatName);
467 aFmt.SetBulletRelSize(45);
468 pActNum->SetLevel(i, aFmt);
470 nMask <<= 1;
475 IMPL_LINK_NOARG(SvxBulletPickTabPage, DoubleClickHdl_Impl, SvtValueSet*, void)
477 NumSelectHdl_Impl(m_xExamplesVS.get());
478 weld::Button& rOk = GetDialogController()->GetOKButton();
479 rOk.clicked();
482 void SvxBulletPickTabPage::PageCreated(const SfxAllItemSet& aSet)
484 const SfxStringItem* pBulletCharFmt = aSet.GetItem<SfxStringItem>(SID_BULLET_CHAR_FMT, false);
486 if (pBulletCharFmt)
487 sBulletCharFormatName = pBulletCharFmt->GetValue();
490 SvxNumPickTabPage::SvxNumPickTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
491 : SfxTabPage(pPage, pController, "cui/ui/pickoutlinepage.ui", "PickOutlinePage", &rSet)
492 , nActNumLvl(SAL_MAX_UINT16)
493 , nNumItemId(SID_ATTR_NUMBERING_RULE)
494 , bModified(false)
495 , bPreset(false)
496 , m_xExamplesVS(new NumValueSet(nullptr))
497 , m_xExamplesVSWin(new weld::CustomWeld(*m_xBuilder, "valueset", *m_xExamplesVS))
499 SetExchangeSupport();
501 m_xExamplesVS->init(NumberingPageType::OUTLINE);
502 m_xExamplesVS->SetSelectHdl(LINK(this, SvxNumPickTabPage, NumSelectHdl_Impl));
503 m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxNumPickTabPage, DoubleClickHdl_Impl));
505 Reference<XDefaultNumberingProvider> xDefNum = SvxNumOptionsTabPageHelper::GetNumberingProvider();
506 if(xDefNum.is())
508 Sequence<Reference<XIndexAccess> > aOutlineAccess;
509 const Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale();
512 aOutlineAccess = xDefNum->getDefaultOutlineNumberings( rLocale );
514 for(sal_Int32 nItem = 0;
515 nItem < aOutlineAccess.getLength() && nItem < NUM_VALUSET_COUNT;
516 nItem++ )
518 SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[ nItem ];
520 Reference<XIndexAccess> xLevel = aOutlineAccess.getConstArray()[nItem];
521 for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++)
523 Any aValueAny = xLevel->getByIndex(nLevel);
524 Sequence<PropertyValue> aLevelProps;
525 aValueAny >>= aLevelProps;
526 SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(aLevelProps);
527 rItemArr.push_back( std::unique_ptr<SvxNumSettings_Impl>(pNew) );
531 catch(const Exception&)
534 Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
535 m_xExamplesVS->SetOutlineNumberingSettings(aOutlineAccess, xFormat, rLocale);
539 SvxNumPickTabPage::~SvxNumPickTabPage()
541 m_xExamplesVSWin.reset();
542 m_xExamplesVS.reset();
545 std::unique_ptr<SfxTabPage> SvxNumPickTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
546 const SfxItemSet* rAttrSet)
548 return std::make_unique<SvxNumPickTabPage>(pPage, pController, *rAttrSet);
551 bool SvxNumPickTabPage::FillItemSet( SfxItemSet* rSet )
553 if( (bPreset || bModified) && pActNum)
555 *pSaveNum = *pActNum;
556 rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ));
557 rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
559 return bModified;
562 void SvxNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
564 const SfxPoolItem* pItem;
565 bPreset = false;
566 bool bIsPreset = false;
567 const SfxItemSet* pExampleSet = GetDialogExampleSet();
568 if(pExampleSet)
570 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
571 bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue();
572 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
573 nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
575 if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
577 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
579 if(pActNum && *pSaveNum != *pActNum)
581 *pActNum = *pSaveNum;
582 m_xExamplesVS->SetNoSelection();
585 if(pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset))
587 m_xExamplesVS->SelectItem(1);
588 NumSelectHdl_Impl(m_xExamplesVS.get());
589 bPreset = true;
591 bPreset |= bIsPreset;
592 bModified = false;
595 DeactivateRC SvxNumPickTabPage::DeactivatePage(SfxItemSet *_pSet)
597 if(_pSet)
598 FillItemSet(_pSet);
599 return DeactivateRC::LeavePage;
602 void SvxNumPickTabPage::Reset( const SfxItemSet* rSet )
604 const SfxPoolItem* pItem;
605 // in Draw the item exists as WhichId, in Writer only as SlotId
606 SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
607 if(eState != SfxItemState::SET)
609 nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
610 eState = rSet->GetItemState(nNumItemId, false, &pItem);
612 if( eState != SfxItemState::SET )
614 pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
615 eState = SfxItemState::SET;
619 DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
620 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
622 if(!pActNum)
623 pActNum.reset( new SvxNumRule(*pSaveNum) );
624 else if(*pSaveNum != *pActNum)
625 *pActNum = *pSaveNum;
629 // all levels are changed here
630 IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, SvtValueSet*, void)
632 if(pActNum)
634 bPreset = false;
635 bModified = true;
637 const FontList* pList = nullptr;
639 SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[m_xExamplesVS->GetSelectedItemId() - 1];
641 const vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont();
642 SvxNumSettings_Impl* pLevelSettings = nullptr;
643 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
645 if(rItemArr.size() > i)
646 pLevelSettings = rItemArr[i].get();
647 if(!pLevelSettings)
648 break;
649 SvxNumberFormat aFmt(pActNum->GetLevel(i));
650 aFmt.SetNumberingType( pLevelSettings->nNumberType );
651 sal_uInt16 nUpperLevelOrChar = static_cast<sal_uInt16>(pLevelSettings->nParentNumbering);
652 if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL)
654 // #i93908# clear suffix for bullet lists
655 aFmt.SetPrefix(OUString());
656 aFmt.SetSuffix(OUString());
657 if( !pLevelSettings->sBulletFont.isEmpty() &&
658 pLevelSettings->sBulletFont != rActBulletFont.GetFamilyName())
660 //search for the font
661 if(!pList)
663 SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
664 const SvxFontListItem* pFontListItem =
665 static_cast<const SvxFontListItem*>( pCurDocShell
666 ->GetItem( SID_ATTR_CHAR_FONTLIST ));
667 pList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
669 if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) )
671 FontMetric aFontMetric = pList->Get(
672 pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE);
673 vcl::Font aFont(aFontMetric);
674 aFmt.SetBulletFont(&aFont);
676 else
678 //if it cannot be found then create a new one
679 vcl::Font aCreateFont( pLevelSettings->sBulletFont,
680 OUString(), Size( 0, 14 ) );
681 aCreateFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW );
682 aCreateFont.SetFamily( FAMILY_DONTKNOW );
683 aCreateFont.SetPitch( PITCH_DONTKNOW );
684 aCreateFont.SetWeight( WEIGHT_DONTKNOW );
685 aCreateFont.SetTransparent( true );
686 aFmt.SetBulletFont( &aCreateFont );
689 else
690 aFmt.SetBulletFont( &rActBulletFont );
692 aFmt.SetBulletChar( !pLevelSettings->sBulletChar.isEmpty()
693 ? pLevelSettings->sBulletChar[0]
694 : 0 );
695 aFmt.SetCharFormatName( sBulletCharFormatName );
696 aFmt.SetBulletRelSize(45);
698 else
700 aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? pActNum->GetLevelCount() : 0));
701 aFmt.SetCharFormatName(sNumCharFmtName);
702 aFmt.SetBulletRelSize(100);
703 // #i93908#
704 aFmt.SetPrefix(pLevelSettings->sPrefix);
705 aFmt.SetSuffix(pLevelSettings->sSuffix);
707 pActNum->SetLevel(i, aFmt);
712 IMPL_LINK_NOARG(SvxNumPickTabPage, DoubleClickHdl_Impl, SvtValueSet*, void)
714 NumSelectHdl_Impl(m_xExamplesVS.get());
715 weld::Button& rOk = GetDialogController()->GetOKButton();
716 rOk.clicked();
719 void SvxNumPickTabPage::PageCreated(const SfxAllItemSet& aSet)
721 const SfxStringItem* pNumCharFmt = aSet.GetItem<SfxStringItem>(SID_NUM_CHAR_FMT, false);
722 const SfxStringItem* pBulletCharFmt = aSet.GetItem<SfxStringItem>(SID_BULLET_CHAR_FMT, false);
725 if (pNumCharFmt &&pBulletCharFmt)
726 SetCharFormatNames( pNumCharFmt->GetValue(),pBulletCharFmt->GetValue());
729 SvxBitmapPickTabPage::SvxBitmapPickTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
730 : SfxTabPage(pPage, pController, "cui/ui/pickgraphicpage.ui", "PickGraphicPage", &rSet)
731 , nActNumLvl(SAL_MAX_UINT16)
732 , nNumItemId(SID_ATTR_NUMBERING_RULE)
733 , bModified(false)
734 , bPreset(false)
735 , m_xErrorText(m_xBuilder->weld_label("errorft"))
736 , m_xBtBrowseFile(m_xBuilder->weld_button("browseBtn"))
737 , m_xExamplesVS(new SvxBmpNumValueSet(m_xBuilder->weld_scrolled_window("valuesetwin")))
738 , m_xExamplesVSWin(new weld::CustomWeld(*m_xBuilder, "valueset", *m_xExamplesVS))
740 SetExchangeSupport();
742 m_xExamplesVS->init();
743 m_xExamplesVS->SetSelectHdl(LINK(this, SvxBitmapPickTabPage, NumSelectHdl_Impl));
744 m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxBitmapPickTabPage, DoubleClickHdl_Impl));
745 m_xBtBrowseFile->connect_clicked(LINK(this, SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl));
747 eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
749 // determine graphic name
750 GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames);
752 size_t i = 0;
753 for (auto & grfName : aGrfNames)
755 m_xExamplesVS->InsertItem( i + 1, i);
757 INetURLObject aObj(grfName);
758 if(aObj.GetProtocol() == INetProtocol::File)
759 grfName = aObj.PathToFileName();
761 m_xExamplesVS->SetItemText( i + 1, grfName );
762 ++i;
765 if(aGrfNames.empty())
767 m_xErrorText->show();
769 else
771 m_xExamplesVS->Show();
772 m_xExamplesVS->SetFormat();
773 m_xExamplesVS->Invalidate();
777 SvxBitmapPickTabPage::~SvxBitmapPickTabPage()
779 m_xExamplesVSWin.reset();
780 m_xExamplesVS.reset();
783 std::unique_ptr<SfxTabPage> SvxBitmapPickTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
784 const SfxItemSet* rAttrSet)
786 return std::make_unique<SvxBitmapPickTabPage>(pPage, pController, *rAttrSet);
789 void SvxBitmapPickTabPage::ActivatePage(const SfxItemSet& rSet)
791 const SfxPoolItem* pItem;
792 bPreset = false;
793 bool bIsPreset = false;
794 const SfxItemSet* pExampleSet = GetDialogExampleSet();
795 if(pExampleSet)
797 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
798 bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue();
799 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
800 nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
802 if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
804 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
806 if(pActNum && *pSaveNum != *pActNum)
808 *pActNum = *pSaveNum;
809 m_xExamplesVS->SetNoSelection();
812 if(!aGrfNames.empty() &&
813 (pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset)))
815 m_xExamplesVS->SelectItem(1);
816 NumSelectHdl_Impl(m_xExamplesVS.get());
817 bPreset = true;
819 bPreset |= bIsPreset;
820 bModified = false;
823 DeactivateRC SvxBitmapPickTabPage::DeactivatePage(SfxItemSet *_pSet)
825 if(_pSet)
826 FillItemSet(_pSet);
827 return DeactivateRC::LeavePage;
830 bool SvxBitmapPickTabPage::FillItemSet( SfxItemSet* rSet )
832 if ( aGrfNames.empty() )
834 return false;
836 if( (bPreset || bModified) && pActNum)
838 *pSaveNum = *pActNum;
839 rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ) );
840 rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
843 return bModified;
846 void SvxBitmapPickTabPage::Reset( const SfxItemSet* rSet )
848 const SfxPoolItem* pItem;
849 // in Draw the item exists as WhichId, in Writer only as SlotId
850 SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
851 if(eState != SfxItemState::SET)
853 nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
854 eState = rSet->GetItemState(nNumItemId, false, &pItem);
856 if( eState != SfxItemState::SET )
858 pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
859 eState = SfxItemState::SET;
863 DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
864 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
866 if(!pActNum)
867 pActNum.reset( new SvxNumRule(*pSaveNum) );
868 else if(*pSaveNum != *pActNum)
869 *pActNum = *pSaveNum;
872 IMPL_LINK_NOARG(SvxBitmapPickTabPage, NumSelectHdl_Impl, SvtValueSet*, void)
874 if(pActNum)
876 bPreset = false;
877 bModified = true;
878 sal_uInt16 nIdx = m_xExamplesVS->GetSelectedItemId() - 1;
880 sal_uInt16 nMask = 1;
881 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
883 if(nActNumLvl & nMask)
885 SvxNumberFormat aFmt(pActNum->GetLevel(i));
886 aFmt.SetNumberingType(SVX_NUM_BITMAP);
887 aFmt.SetPrefix( "" );
888 aFmt.SetSuffix( "" );
889 aFmt.SetCharFormatName( "" );
891 Graphic aGraphic;
892 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nIdx, &aGraphic))
894 Size aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
895 sal_Int16 eOrient = text::VertOrientation::LINE_CENTER;
896 aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit));
897 SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH );
898 aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient );
900 else if(aGrfNames.size() > nIdx)
901 aFmt.SetGraphic( aGrfNames[nIdx] );
902 pActNum->SetLevel(i, aFmt);
904 nMask <<= 1;
909 IMPL_LINK_NOARG(SvxBitmapPickTabPage, DoubleClickHdl_Impl, SvtValueSet*, void)
911 NumSelectHdl_Impl(m_xExamplesVS.get());
912 weld::Button& rOk = GetDialogController()->GetOKButton();
913 rOk.clicked();
916 IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, void)
918 sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, GetFrameWeld());
919 aFileDialog.SetTitle(CuiResId(RID_SVXSTR_ADD_IMAGE));
920 if ( aFileDialog.Execute() != ERRCODE_NONE )
921 return;
923 OUString aPath = SvtPathOptions().GetGalleryPath();
924 OUString aPathToken = aPath.getToken( 1 , SEARCHPATH_DELIMITER );
926 OUString aUserImageURL = aFileDialog.GetPath();
928 OUString aFileName;
929 const sal_Int32 nPos {aUserImageURL.lastIndexOf(SEARCHFILENAME_DELIMITER)+1};
930 if (nPos<=0)
931 aFileName = aUserImageURL;
932 else if (nPos<aUserImageURL.getLength())
933 aFileName = aUserImageURL.copy(nPos);
935 OUString aUserGalleryURL = aPathToken + "/" + aFileName;
936 INetURLObject aURL( aUserImageURL );
937 DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
939 GraphicDescriptor aDescriptor(aURL);
940 if (aDescriptor.Detect())
942 uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
943 uno::Reference<ucb::XSimpleFileAccess3> xSimpleFileAccess(
944 ucb::SimpleFileAccess::create( ::comphelper::getComponentContext(xFactory) ) );
945 if ( xSimpleFileAccess->exists( aUserImageURL ))
947 xSimpleFileAccess->copy( aUserImageURL, aUserGalleryURL );
948 INetURLObject gURL( aUserGalleryURL );
949 std::unique_ptr<SvStream> pIn(::utl::UcbStreamHelper::CreateStream(
950 gURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
951 if ( pIn )
953 Graphic aGraphic;
954 GraphicConverter::Import( *pIn, aGraphic );
956 BitmapEx aBitmap = aGraphic.GetBitmapEx();
957 long nPixelX = aBitmap.GetSizePixel().Width();
958 long nPixelY = aBitmap.GetSizePixel().Height();
959 double ratio = nPixelY/static_cast<double>(nPixelX);
960 if(nPixelX > 30)
962 nPixelX = 30;
963 nPixelY = static_cast<long>(nPixelX*ratio);
965 if(nPixelY > 30)
967 nPixelY = 30;
968 nPixelX = static_cast<long>(nPixelY/ratio);
971 aBitmap.Scale( Size( nPixelX, nPixelY ), BmpScaleFlag::Fast );
972 Graphic aScaledGraphic( aBitmap );
973 GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
975 Sequence< PropertyValue > aFilterData( 2 );
976 aFilterData[ 0 ].Name = "Compression";
977 aFilterData[ 0 ].Value <<= sal_Int32(-1) ;
978 aFilterData[ 1 ].Name = "Quality";
979 aFilterData[ 1 ].Value <<= sal_Int32(1);
981 sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( gURL.GetFileExtension() );
982 rFilter.ExportGraphic( aScaledGraphic, gURL , nFilterFormat, &aFilterData );
983 GalleryExplorer::InsertURL( GALLERY_THEME_BULLETS, aUserGalleryURL );
985 aGrfNames.push_back(aUserGalleryURL);
986 size_t i = 0;
987 for (auto & grfName : aGrfNames)
989 m_xExamplesVS->InsertItem( i + 1, i);
990 INetURLObject aObj(grfName);
991 if(aObj.GetProtocol() == INetProtocol::File)
992 grfName = aObj.PathToFileName();
993 m_xExamplesVS->SetItemText( i + 1, grfName );
994 ++i;
997 if(aGrfNames.empty())
999 m_xErrorText->show();
1001 else
1003 m_xExamplesVS->Show();
1004 m_xExamplesVS->SetFormat();
1013 // tabpage numbering options
1014 SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogController* pController,
1015 const SfxItemSet& rSet)
1016 : SfxTabPage(pPage, pController, "cui/ui/numberingoptionspage.ui", "NumberingOptionsPage", &rSet)
1017 , m_pLevelHdlEvent(nullptr)
1018 , bLastWidthModified(false)
1019 , bModified(false)
1020 , bPreset(false)
1021 , bAutomaticCharStyles(true)
1022 , bHTMLMode(false)
1023 , nBullet(0xff)
1024 , nActNumLvl(1)
1025 , nNumItemId(SID_ATTR_NUMBERING_RULE)
1026 , m_xGrid(m_xBuilder->weld_widget("grid2"))
1027 , m_xLevelLB(m_xBuilder->weld_tree_view("levellb"))
1028 , m_xFmtLB(m_xBuilder->weld_combo_box("numfmtlb"))
1029 , m_xSeparatorFT(m_xBuilder->weld_label("separator"))
1030 , m_xPrefixFT(m_xBuilder->weld_label("prefixft"))
1031 , m_xPrefixED(m_xBuilder->weld_entry("prefix"))
1032 , m_xSuffixFT(m_xBuilder->weld_label("suffixft"))
1033 , m_xSuffixED(m_xBuilder->weld_entry("suffix"))
1034 , m_xCharFmtFT(m_xBuilder->weld_label("charstyleft"))
1035 , m_xCharFmtLB(m_xBuilder->weld_combo_box("charstyle"))
1036 , m_xBulColorFT(m_xBuilder->weld_label("colorft"))
1037 , m_xBulColLB(new ColorListBox(m_xBuilder->weld_menu_button("color"), pController->getDialog()))
1038 , m_xBulRelSizeFT(m_xBuilder->weld_label("relsizeft"))
1039 , m_xBulRelSizeMF(m_xBuilder->weld_metric_spin_button("relsize", FieldUnit::PERCENT))
1040 , m_xAllLevelFT(m_xBuilder->weld_label("sublevelsft"))
1041 , m_xAllLevelNF(m_xBuilder->weld_spin_button("sublevels"))
1042 , m_xStartFT(m_xBuilder->weld_label("startatft"))
1043 , m_xStartED(m_xBuilder->weld_spin_button("startat"))
1044 , m_xBulletFT(m_xBuilder->weld_label("bulletft"))
1045 , m_xBulletPB(m_xBuilder->weld_button("bullet"))
1046 , m_xBitmapFT(m_xBuilder->weld_label("bitmapft"))
1047 , m_xBitmapMB(m_xBuilder->weld_menu_button("bitmap"))
1048 , m_xWidthFT(m_xBuilder->weld_label("widthft"))
1049 , m_xWidthMF(m_xBuilder->weld_metric_spin_button("widthmf", FieldUnit::CM))
1050 , m_xHeightFT(m_xBuilder->weld_label("heightft"))
1051 , m_xHeightMF(m_xBuilder->weld_metric_spin_button("heightmf", FieldUnit::CM))
1052 , m_xRatioCB(m_xBuilder->weld_check_button("keepratio"))
1053 , m_xOrientFT(m_xBuilder->weld_label("orientft"))
1054 , m_xOrientLB(m_xBuilder->weld_combo_box("orientlb"))
1055 , m_xAllLevelsFrame(m_xBuilder->weld_widget("levelsframe"))
1056 , m_xSameLevelCB(m_xBuilder->weld_check_button("allsame"))
1057 , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN))
1059 m_xBulColLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1060 m_xBulRelSizeMF->set_min(SVX_NUM_REL_SIZE_MIN, FieldUnit::PERCENT);
1061 m_xBulRelSizeMF->set_increments(5, 50, FieldUnit::PERCENT);
1062 SetExchangeSupport();
1063 aActBulletFont = lcl_GetDefaultBulletFont();
1065 m_xBulletPB->connect_clicked(LINK(this, SvxNumOptionsTabPage, BulletHdl_Impl));
1066 m_xFmtLB->connect_changed(LINK(this, SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl));
1067 m_xBitmapMB->connect_selected(LINK(this, SvxNumOptionsTabPage, GraphicHdl_Impl));
1068 m_xBitmapMB->connect_toggled(LINK(this, SvxNumOptionsTabPage, PopupActivateHdl_Impl));
1069 m_xLevelLB->set_selection_mode(SelectionMode::Multiple);
1070 m_xLevelLB->connect_changed(LINK(this, SvxNumOptionsTabPage, LevelHdl_Impl));
1071 m_xCharFmtLB->connect_changed(LINK(this, SvxNumOptionsTabPage, CharFmtHdl_Impl));
1072 m_xWidthMF->connect_value_changed(LINK(this, SvxNumOptionsTabPage, SizeHdl_Impl));
1073 m_xHeightMF->connect_value_changed(LINK(this, SvxNumOptionsTabPage, SizeHdl_Impl));
1074 m_xRatioCB->connect_toggled(LINK(this, SvxNumOptionsTabPage, RatioHdl_Impl));
1075 m_xStartED->connect_value_changed(LINK(this, SvxNumOptionsTabPage, SpinModifyHdl_Impl));
1076 m_xPrefixED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1077 m_xSuffixED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1078 m_xAllLevelNF->connect_value_changed(LINK(this,SvxNumOptionsTabPage, AllLevelHdl_Impl));
1079 m_xOrientLB->connect_changed(LINK(this, SvxNumOptionsTabPage, OrientHdl_Impl));
1080 m_xSameLevelCB->connect_toggled(LINK(this, SvxNumOptionsTabPage, SameLevelHdl_Impl));
1081 m_xBulRelSizeMF->connect_value_changed(LINK(this,SvxNumOptionsTabPage, BulRelSizeHdl_Impl));
1082 m_xBulColLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, BulColorHdl_Impl));
1083 aInvalidateTimer.SetInvokeHandler(LINK(this, SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl));
1084 aInvalidateTimer.SetTimeout(50);
1086 eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
1088 // Fill ListBox with predefined / translated numbering types.
1089 sal_uInt32 nCount = SvxNumberingTypeTable::Count();
1090 for (sal_uInt32 i = 0; i < nCount; ++i)
1092 m_xFmtLB->append(OUString::number(SvxNumberingTypeTable::GetValue(i)), SvxNumberingTypeTable::GetString(i));
1095 // Get advanced numbering types from the component.
1096 // Watch out for the ugly
1097 // 136 == 0x88 == SVX_NUM_BITMAP|0x80 == SVX_NUM_BITMAP|LINK_TOKEN
1098 // to not remove that.
1099 SvxNumOptionsTabPageHelper::GetI18nNumbering( *m_xFmtLB, (SVX_NUM_BITMAP | LINK_TOKEN));
1101 m_xFmtLB->set_active(0);
1103 m_xCharFmtLB->set_size_request(m_xCharFmtLB->get_approximate_digit_width() * 10, -1);
1104 Size aSize(m_xGrid->get_preferred_size());
1105 m_xGrid->set_size_request(aSize.Width(), -1);
1108 SvxNumOptionsTabPage::~SvxNumOptionsTabPage()
1110 m_xPreviewWIN.reset();
1111 m_xBulColLB.reset();
1112 pActNum.reset();
1113 pSaveNum.reset();
1114 if (m_pLevelHdlEvent)
1116 Application::RemoveUserEvent(m_pLevelHdlEvent);
1117 m_pLevelHdlEvent = nullptr;
1121 void SvxNumOptionsTabPage::SetMetric(FieldUnit eMetric)
1123 if(eMetric == FieldUnit::MM)
1125 m_xWidthMF->set_digits(1);
1126 m_xHeightMF->set_digits(1);
1128 m_xWidthMF->set_unit(eMetric);
1129 m_xHeightMF->set_unit(eMetric);
1132 std::unique_ptr<SfxTabPage> SvxNumOptionsTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1133 const SfxItemSet* rAttrSet)
1135 return std::make_unique<SvxNumOptionsTabPage>(pPage, pController, *rAttrSet);
1138 void SvxNumOptionsTabPage::ActivatePage(const SfxItemSet& rSet)
1140 const SfxPoolItem* pItem;
1141 const SfxItemSet* pExampleSet = GetDialogExampleSet();
1142 sal_uInt16 nTmpNumLvl = 1;
1143 if(pExampleSet)
1145 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
1146 bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1147 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
1148 nTmpNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1150 if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
1152 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
1155 bModified = (!pActNum->Get( 0 ) || bPreset);
1156 if(*pActNum != *pSaveNum ||
1157 nActNumLvl != nTmpNumLvl)
1159 nActNumLvl = nTmpNumLvl;
1160 sal_uInt16 nMask = 1;
1161 m_xLevelLB->unselect_all();
1162 if (nActNumLvl == SAL_MAX_UINT16)
1163 m_xLevelLB->select(pActNum->GetLevelCount());
1164 if(nActNumLvl != SAL_MAX_UINT16)
1166 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1168 if(nActNumLvl & nMask)
1169 m_xLevelLB->select(i);
1170 nMask <<= 1 ;
1173 *pActNum = *pSaveNum;
1175 InitControls();
1179 DeactivateRC SvxNumOptionsTabPage::DeactivatePage(SfxItemSet * _pSet)
1181 if(_pSet)
1182 FillItemSet(_pSet);
1183 return DeactivateRC::LeavePage;
1186 bool SvxNumOptionsTabPage::FillItemSet( SfxItemSet* rSet )
1188 rSet->Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
1189 if(bModified && pActNum)
1191 *pSaveNum = *pActNum;
1192 rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ));
1193 rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, false));
1195 return bModified;
1198 void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet )
1200 const SfxPoolItem* pItem;
1201 // in Draw the item exists as WhichId, in Writer only as SlotId
1202 SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
1203 if(eState != SfxItemState::SET)
1205 nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
1206 eState = rSet->GetItemState(nNumItemId, false, &pItem);
1208 if( eState != SfxItemState::SET )
1210 pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
1211 eState = SfxItemState::SET;
1215 DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
1216 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
1218 // insert levels
1219 if (!m_xLevelLB->n_children())
1221 for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
1222 m_xLevelLB->append_text(OUString::number(i));
1223 if(pSaveNum->GetLevelCount() > 1)
1225 OUString sEntry = "1 - " + OUString::number( pSaveNum->GetLevelCount() );
1226 m_xLevelLB->append_text(sEntry);
1227 m_xLevelLB->select_text(sEntry);
1229 else
1230 m_xLevelLB->select(0);
1232 else
1233 m_xLevelLB->select(m_xLevelLB->n_children() - 1);
1235 sal_uInt16 nMask = 1;
1236 m_xLevelLB->unselect_all();
1237 if (nActNumLvl == SAL_MAX_UINT16)
1239 m_xLevelLB->select( pSaveNum->GetLevelCount() );
1241 else
1243 for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
1245 if(nActNumLvl & nMask)
1246 m_xLevelLB->select( i );
1247 nMask <<= 1 ;
1251 if(!pActNum)
1252 pActNum.reset( new SvxNumRule(*pSaveNum) );
1253 else if(*pSaveNum != *pActNum)
1254 *pActNum = *pSaveNum;
1255 m_aPreviewWIN.SetNumRule(pActNum.get());
1256 m_xSameLevelCB->set_active(pActNum->IsContinuousNumbering());
1258 SfxObjectShell* pShell;
1259 if ( SfxItemState::SET == rSet->GetItemState( SID_HTML_MODE, false, &pItem )
1260 || ( nullptr != ( pShell = SfxObjectShell::Current()) &&
1261 nullptr != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
1263 sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1264 bHTMLMode = 0 != (nHtmlMode&HTMLMODE_ON);
1267 bool bCharFmt = pActNum->IsFeatureSupported(SvxNumRuleFlags::CHAR_STYLE);
1268 m_xCharFmtFT->set_visible(bCharFmt);
1269 m_xCharFmtLB->set_visible(bCharFmt);
1271 bool bContinuous = pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS);
1273 bool bAllLevel = bContinuous && !bHTMLMode;
1274 m_xAllLevelFT->set_visible(bAllLevel);
1275 m_xAllLevelNF->set_visible(bAllLevel);
1277 m_xAllLevelsFrame->set_visible(bContinuous);
1279 // again misusage: in Draw there is numeration only until the bitmap
1280 // without SVX_NUM_NUMBER_NONE
1281 //remove types that are unsupported by Draw/Impress
1282 if(!bContinuous)
1284 sal_Int32 nFmtCount = m_xFmtLB->get_count();
1285 for(sal_Int32 i = nFmtCount; i; i--)
1287 sal_uInt16 nEntryData = m_xFmtLB->get_id(i - 1).toUInt32();
1288 if(/*SVX_NUM_NUMBER_NONE == nEntryData ||*/
1289 (SVX_NUM_BITMAP|LINK_TOKEN) == nEntryData)
1290 m_xFmtLB->remove(i - 1);
1293 //one must be enabled
1294 if(!pActNum->IsFeatureSupported(SvxNumRuleFlags::ENABLE_LINKED_BMP))
1296 auto nPos = m_xFmtLB->find_id(OUString::number(SVX_NUM_BITMAP|LINK_TOKEN));
1297 if (nPos != -1)
1298 m_xFmtLB->remove(nPos);
1300 else if(!pActNum->IsFeatureSupported(SvxNumRuleFlags::ENABLE_EMBEDDED_BMP))
1302 auto nPos = m_xFmtLB->find_id(OUString::number(SVX_NUM_BITMAP));
1303 if (nPos != -1)
1304 m_xFmtLB->remove(nPos);
1307 // MegaHack: because of a not-fixable 'design mistake/error' in Impress
1308 // delete all kinds of numeric enumerations
1309 if(pActNum->IsFeatureSupported(SvxNumRuleFlags::NO_NUMBERS))
1311 sal_Int32 nFmtCount = m_xFmtLB->get_count();
1312 for(sal_Int32 i = nFmtCount; i; i--)
1314 sal_uInt16 nEntryData = m_xFmtLB->get_id(i - 1).toUInt32();
1315 if( /*nEntryData >= SVX_NUM_CHARS_UPPER_LETTER &&*/ nEntryData <= SVX_NUM_NUMBER_NONE)
1316 m_xFmtLB->remove(i - 1);
1320 InitControls();
1321 bModified = false;
1324 void SvxNumOptionsTabPage::InitControls()
1326 bool bShowBullet = true;
1327 bool bShowBitmap = true;
1328 bool bSameType = true;
1329 bool bSameStart = true;
1330 bool bSamePrefix = true;
1331 bool bSameSuffix = true;
1332 bool bAllLevel = true;
1333 bool bSameCharFmt = true;
1334 bool bSameVOrient = true;
1335 bool bSameSize = true;
1336 bool bSameBulColor = true;
1337 bool bSameBulRelSize= true;
1339 const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
1340 OUString sFirstCharFmt;
1341 sal_Int16 eFirstOrient = text::VertOrientation::NONE;
1342 Size aFirstSize(0,0);
1343 sal_uInt16 nMask = 1;
1344 sal_uInt16 nLvl = SAL_MAX_UINT16;
1345 sal_uInt16 nHighestLevel = 0;
1347 bool bBullColor = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR);
1348 bool bBullRelSize = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE);
1349 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1351 if(nActNumLvl & nMask)
1353 aNumFmtArr[i] = &pActNum->GetLevel(i);
1354 bShowBullet &= aNumFmtArr[i]->GetNumberingType() == SVX_NUM_CHAR_SPECIAL;
1355 bShowBitmap &= (aNumFmtArr[i]->GetNumberingType()&(~LINK_TOKEN)) == SVX_NUM_BITMAP;
1356 if(SAL_MAX_UINT16 == nLvl)
1358 nLvl = i;
1359 sFirstCharFmt = aNumFmtArr[i]->GetCharFormatName();
1360 eFirstOrient = aNumFmtArr[i]->GetVertOrient();
1361 if(bShowBitmap)
1362 aFirstSize = aNumFmtArr[i]->GetGraphicSize();
1364 if( i > nLvl)
1366 bSameType &= aNumFmtArr[i]->GetNumberingType() == aNumFmtArr[nLvl]->GetNumberingType();
1367 bSameStart = aNumFmtArr[i]->GetStart() == aNumFmtArr[nLvl]->GetStart();
1369 bSamePrefix = aNumFmtArr[i]->GetPrefix() == aNumFmtArr[nLvl]->GetPrefix();
1370 bSameSuffix = aNumFmtArr[i]->GetSuffix() == aNumFmtArr[nLvl]->GetSuffix();
1371 bAllLevel &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[nLvl]->GetIncludeUpperLevels();
1372 bSameCharFmt &= sFirstCharFmt == aNumFmtArr[i]->GetCharFormatName();
1373 bSameVOrient &= eFirstOrient == aNumFmtArr[i]->GetVertOrient();
1374 if(bShowBitmap && bSameSize)
1375 bSameSize &= aNumFmtArr[i]->GetGraphicSize() == aFirstSize;
1376 bSameBulColor &= aNumFmtArr[i]->GetBulletColor() == aNumFmtArr[nLvl]->GetBulletColor();
1377 bSameBulRelSize &= aNumFmtArr[i]->GetBulletRelSize() == aNumFmtArr[nLvl]->GetBulletRelSize();
1379 nHighestLevel = i;
1381 else
1382 aNumFmtArr[i] = nullptr;
1384 nMask <<= 1 ;
1386 SwitchNumberType(bShowBullet ? 1 : bShowBitmap ? 2 : 0);
1388 sal_uInt16 nNumberingType;
1389 if (nLvl != SAL_MAX_UINT16)
1390 nNumberingType = aNumFmtArr[nLvl]->GetNumberingType();
1391 else
1393 nNumberingType = SVX_NUM_NUMBER_NONE;
1394 bAllLevel = false;
1395 bSameBulRelSize = false;
1396 bSameBulColor = false;
1397 bSameStart = false;
1398 bSamePrefix = false;
1399 bSameSuffix = false;
1402 CheckForStartValue_Impl(nNumberingType);
1404 if(bShowBitmap)
1406 if(!bSameVOrient || eFirstOrient == text::VertOrientation::NONE)
1407 m_xOrientLB->set_active(-1);
1408 else
1409 m_xOrientLB->set_active(
1410 sal::static_int_cast< sal_Int32 >(eFirstOrient - 1));
1411 // no text::VertOrientation::NONE
1413 if(bSameSize)
1415 SetMetricValue(*m_xHeightMF, aFirstSize.Height(), eCoreUnit);
1416 SetMetricValue(*m_xWidthMF, aFirstSize.Width(), eCoreUnit);
1418 else
1420 m_xHeightMF->set_text("");
1421 m_xWidthMF->set_text("");
1425 if(bSameType)
1427 sal_uInt16 nLBData = nNumberingType;
1428 m_xFmtLB->set_active_id(OUString::number(nLBData));
1430 else
1431 m_xFmtLB->set_active(-1);
1433 m_xAllLevelNF->set_sensitive(nHighestLevel > 0 && !m_xSameLevelCB->get_active());
1434 m_xAllLevelNF->set_max(nHighestLevel + 1);
1435 if(bAllLevel)
1437 m_xAllLevelNF->set_value(aNumFmtArr[nLvl]->GetIncludeUpperLevels());
1439 else
1441 m_xAllLevelNF->set_text("");
1444 if(bBullRelSize)
1446 if(bSameBulRelSize)
1447 m_xBulRelSizeMF->set_value(aNumFmtArr[nLvl]->GetBulletRelSize(), FieldUnit::PERCENT);
1448 else
1449 m_xBulRelSizeMF->set_text("");
1451 if(bBullColor)
1453 if(bSameBulColor)
1454 m_xBulColLB->SelectEntry(aNumFmtArr[nLvl]->GetBulletColor());
1455 else
1456 m_xBulColLB->SetNoSelection();
1458 switch(nBullet)
1460 case SHOW_NUMBERING:
1461 if(bSameStart)
1463 m_xStartED->set_value(aNumFmtArr[nLvl]->GetStart());
1465 else
1466 m_xStartED->set_text("");
1467 break;
1468 case SHOW_BULLET:
1469 break;
1470 case SHOW_BITMAP:
1471 break;
1474 if(bSamePrefix)
1475 m_xPrefixED->set_text(aNumFmtArr[nLvl]->GetPrefix());
1476 else
1477 m_xPrefixED->set_text("");
1478 if(bSameSuffix)
1479 m_xSuffixED->set_text(aNumFmtArr[nLvl]->GetSuffix());
1480 else
1481 m_xSuffixED->set_text("");
1483 if(bSameCharFmt)
1485 if (!sFirstCharFmt.isEmpty())
1486 m_xCharFmtLB->set_active_text(sFirstCharFmt);
1487 else
1488 m_xCharFmtLB->set_active(0);
1490 else
1491 m_xCharFmtLB->set_active(-1);
1493 m_aPreviewWIN.SetLevel(nActNumLvl);
1494 m_aPreviewWIN.Invalidate();
1497 // 0 - Number; 1 - Bullet; 2 - Bitmap
1498 void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType )
1500 if(nBullet == nType)
1501 return;
1502 nBullet = nType;
1503 bool bBullet = (nType == SHOW_BULLET);
1504 bool bBitmap = (nType == SHOW_BITMAP);
1505 bool bEnableBitmap = (nType == SHOW_BITMAP);
1506 bool bNumeric = !(bBitmap||bBullet);
1507 m_xSeparatorFT->set_visible(bNumeric);
1508 m_xPrefixFT->set_visible(bNumeric);
1509 m_xPrefixED->set_visible(bNumeric);
1510 m_xSuffixFT->set_visible(bNumeric);
1511 m_xSuffixED->set_visible(bNumeric);
1513 bool bCharFmt = pActNum->IsFeatureSupported(SvxNumRuleFlags::CHAR_STYLE);
1514 m_xCharFmtFT->set_visible(!bBitmap && bCharFmt);
1515 m_xCharFmtLB->set_visible(!bBitmap && bCharFmt);
1517 // this is rather misusage, as there is no own flag
1518 // for complete numeration
1519 bool bAllLevelFeature = pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS);
1520 bool bAllLevel = bNumeric && bAllLevelFeature && !bHTMLMode;
1521 m_xAllLevelFT->set_visible(bAllLevel);
1522 m_xAllLevelNF->set_visible(bAllLevel);
1524 m_xStartFT->set_visible(!(bBullet||bBitmap));
1525 m_xStartED->set_visible(!(bBullet||bBitmap));
1527 m_xBulletFT->set_visible(bBullet);
1528 m_xBulletPB->set_visible(bBullet);
1529 bool bBullColor = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR);
1530 m_xBulColorFT->set_visible(!bBitmap && bBullColor);
1531 m_xBulColLB->set_visible(!bBitmap && bBullColor);
1532 bool bBullResSize = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE);
1533 m_xBulRelSizeFT->set_visible(!bBitmap && bBullResSize);
1534 m_xBulRelSizeMF->set_visible(!bBitmap && bBullResSize);
1536 m_xBitmapFT->set_visible(bBitmap);
1537 m_xBitmapMB->set_visible(bBitmap);
1539 m_xWidthFT->set_visible(bBitmap);
1540 m_xWidthMF->set_visible(bBitmap);
1541 m_xHeightFT->set_visible(bBitmap);
1542 m_xHeightMF->set_visible(bBitmap);
1543 m_xRatioCB->set_visible(bBitmap);
1545 m_xOrientFT->set_visible(bBitmap && bAllLevelFeature);
1546 m_xOrientLB->set_visible(bBitmap && bAllLevelFeature);
1548 m_xWidthFT->set_sensitive(bEnableBitmap);
1549 m_xWidthMF->set_sensitive(bEnableBitmap);
1550 m_xHeightFT->set_sensitive(bEnableBitmap);
1551 m_xHeightMF->set_sensitive(bEnableBitmap);
1552 m_xRatioCB->set_sensitive(bEnableBitmap);
1553 m_xOrientFT->set_sensitive(bEnableBitmap);
1554 m_xOrientLB->set_sensitive(bEnableBitmap);
1557 IMPL_LINK_NOARG(SvxNumOptionsTabPage, LevelHdl_Impl, weld::TreeView&, void)
1559 if (m_pLevelHdlEvent)
1560 return;
1561 // tdf#127112 (borrowing tdf#127120 solution) multiselection may be implemented by deselect follow by select so
1562 // fire off the handler to happen on next event loop and only process the
1563 // final state
1564 m_pLevelHdlEvent = Application::PostUserEvent(LINK(this, SvxNumOptionsTabPage, LevelHdl));
1567 IMPL_LINK_NOARG(SvxNumOptionsTabPage, LevelHdl, void*, void)
1569 m_pLevelHdlEvent = nullptr;
1571 sal_uInt16 nSaveNumLvl = nActNumLvl;
1572 nActNumLvl = 0;
1573 std::vector<int> aSelectedRows = m_xLevelLB->get_selected_rows();
1574 if (std::find(aSelectedRows.begin(), aSelectedRows.end(), pActNum->GetLevelCount()) != aSelectedRows.end() &&
1575 (aSelectedRows.size() == 1 || nSaveNumLvl != 0xffff))
1577 nActNumLvl = 0xFFFF;
1578 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1579 m_xLevelLB->unselect(i);
1581 else if (!aSelectedRows.empty())
1583 sal_uInt16 nMask = 1;
1584 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1586 if (std::find(aSelectedRows.begin(), aSelectedRows.end(), i) != aSelectedRows.end())
1587 nActNumLvl |= nMask;
1588 nMask <<= 1;
1590 m_xLevelLB->unselect(pActNum->GetLevelCount());
1592 else
1594 nActNumLvl = nSaveNumLvl;
1595 sal_uInt16 nMask = 1;
1596 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1598 if(nActNumLvl & nMask)
1600 m_xLevelLB->select(i);
1601 break;
1603 nMask <<=1;
1606 InitControls();
1609 IMPL_LINK_NOARG(SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl, Timer *, void)
1611 m_aPreviewWIN.Invalidate();
1614 IMPL_LINK(SvxNumOptionsTabPage, AllLevelHdl_Impl, weld::SpinButton&, rBox, void)
1616 sal_uInt16 nMask = 1;
1617 for(sal_uInt16 e = 0; e < pActNum->GetLevelCount(); e++)
1619 if(nActNumLvl & nMask)
1621 SvxNumberFormat aNumFmt(pActNum->GetLevel(e));
1622 aNumFmt.SetIncludeUpperLevels(static_cast<sal_uInt8>(std::min(rBox.get_value(), int(e + 1))) );
1623 pActNum->SetLevel(e, aNumFmt);
1625 nMask <<= 1;
1627 SetModified();
1630 IMPL_LINK(SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, weld::ComboBox&, rBox, void)
1632 OUString sSelectStyle;
1633 bool bShowOrient = false;
1634 bool bBmp = false;
1635 sal_uInt16 nMask = 1;
1636 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1638 if(nActNumLvl & nMask)
1640 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1641 // PAGEDESC does not exist
1642 SvxNumType nNumType = static_cast<SvxNumType>(rBox.get_active_id().toUInt32());
1643 aNumFmt.SetNumberingType(nNumType);
1644 sal_uInt16 nNumberingType = aNumFmt.GetNumberingType();
1645 if(SVX_NUM_BITMAP == (nNumberingType&(~LINK_TOKEN)))
1647 bBmp |= nullptr != aNumFmt.GetBrush();
1648 aNumFmt.SetIncludeUpperLevels( 0 );
1649 aNumFmt.SetSuffix( "" );
1650 aNumFmt.SetPrefix( "" );
1651 if(!bBmp)
1652 aNumFmt.SetGraphic("");
1653 pActNum->SetLevel(i, aNumFmt);
1654 SwitchNumberType(SHOW_BITMAP);
1655 bShowOrient = true;
1657 else if( SVX_NUM_CHAR_SPECIAL == nNumberingType )
1659 aNumFmt.SetIncludeUpperLevels( 0 );
1660 aNumFmt.SetSuffix( "" );
1661 aNumFmt.SetPrefix( "" );
1662 if( !aNumFmt.GetBulletFont() )
1663 aNumFmt.SetBulletFont(&aActBulletFont);
1664 if( !aNumFmt.GetBulletChar() )
1665 aNumFmt.SetBulletChar( SVX_DEF_BULLET );
1666 pActNum->SetLevel(i, aNumFmt);
1667 SwitchNumberType(SHOW_BULLET);
1668 // allocation of the drawing pattern is automatic
1669 if(bAutomaticCharStyles)
1671 sSelectStyle = m_sBulletCharFormatName;
1674 else
1676 aNumFmt.SetPrefix( m_xPrefixED->get_text() );
1677 aNumFmt.SetSuffix( m_xSuffixED->get_text() );
1678 SwitchNumberType(SHOW_NUMBERING);
1679 pActNum->SetLevel(i, aNumFmt);
1680 CheckForStartValue_Impl(nNumberingType);
1682 // allocation of the drawing pattern is automatic
1683 if(bAutomaticCharStyles)
1685 sSelectStyle = m_sNumCharFmtName;
1689 nMask <<= 1;
1691 bool bAllLevelFeature = pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS);
1692 if(bShowOrient && bAllLevelFeature)
1694 m_xOrientFT->show();
1695 m_xOrientLB->show();
1697 else
1699 m_xOrientFT->hide();
1700 m_xOrientLB->hide();
1702 SetModified();
1703 if(!sSelectStyle.isEmpty())
1705 m_xCharFmtLB->set_active_text(sSelectStyle);
1706 CharFmtHdl_Impl(*m_xCharFmtLB);
1707 bAutomaticCharStyles = true;
1711 void SvxNumOptionsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType)
1713 bool bIsNull = m_xStartED->get_value() == 0;
1714 bool bNoZeroAllowed = nNumberingType < SVX_NUM_ARABIC ||
1715 SVX_NUM_CHARS_UPPER_LETTER_N == nNumberingType ||
1716 SVX_NUM_CHARS_LOWER_LETTER_N == nNumberingType;
1717 m_xStartED->set_min(bNoZeroAllowed ? 1 : 0);
1718 if (bIsNull && bNoZeroAllowed)
1719 EditModifyHdl_Impl(*m_xStartED);
1722 IMPL_LINK(SvxNumOptionsTabPage, OrientHdl_Impl, weld::ComboBox&, rBox, void)
1724 sal_Int32 nPos = rBox.get_active();
1725 nPos ++; // no VERT_NONE
1727 sal_uInt16 nMask = 1;
1728 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1730 if(nActNumLvl & nMask)
1732 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1733 if(SVX_NUM_BITMAP == (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
1735 const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
1736 const Size& rSize = aNumFmt.GetGraphicSize();
1737 sal_Int16 eOrient = static_cast<sal_Int16>(nPos);
1738 aNumFmt.SetGraphicBrush( pBrushItem, &rSize, &eOrient );
1739 pActNum->SetLevel(i, aNumFmt);
1742 nMask <<= 1;
1744 SetModified(false);
1747 IMPL_LINK(SvxNumOptionsTabPage, SameLevelHdl_Impl, weld::ToggleButton&, rBox, void)
1749 bool bSet = rBox.get_active();
1750 pActNum->SetContinuousNumbering(bSet);
1751 bool bRepaint = false;
1752 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1754 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1755 if(aNumFmt.GetNumberingType() != SVX_NUM_NUMBER_NONE)
1757 bRepaint = true;
1758 break;
1761 SetModified(bRepaint);
1762 InitControls();
1765 IMPL_LINK(SvxNumOptionsTabPage, BulColorHdl_Impl, ColorListBox&, rColorBox, void)
1767 Color nSetColor = rColorBox.GetSelectEntryColor();
1769 sal_uInt16 nMask = 1;
1770 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1772 if(nActNumLvl & nMask)
1774 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1775 aNumFmt.SetBulletColor(nSetColor);
1776 pActNum->SetLevel(i, aNumFmt);
1778 nMask <<= 1;
1780 SetModified();
1783 IMPL_LINK(SvxNumOptionsTabPage, BulRelSizeHdl_Impl, weld::MetricSpinButton&, rField, void)
1785 sal_uInt16 nRelSize = rField.get_value(FieldUnit::PERCENT);
1787 sal_uInt16 nMask = 1;
1788 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1790 if(nActNumLvl & nMask)
1792 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1793 aNumFmt.SetBulletRelSize(nRelSize);
1794 pActNum->SetLevel(i, aNumFmt);
1796 nMask <<= 1;
1798 SetModified();
1801 IMPL_LINK(SvxNumOptionsTabPage, GraphicHdl_Impl, const OString&, rIdent, void)
1803 OUString aGrfName;
1804 Size aSize;
1805 bool bSucc(false);
1806 SvxOpenGraphicDialog aGrfDlg(CuiResId(RID_SVXSTR_EDIT_GRAPHIC), GetFrameWeld());
1808 OString sNumber;
1809 if (rIdent.startsWith("gallery", &sNumber))
1811 auto idx = sNumber.toUInt32();
1812 if (idx < aGrfNames.size())
1814 aGrfName = aGrfNames[idx];
1815 Graphic aGraphic;
1816 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, idx, &aGraphic))
1818 aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
1819 bSucc = true;
1823 else if (rIdent == "fromfile")
1825 aGrfDlg.EnableLink( false );
1826 aGrfDlg.AsLink( false );
1827 if ( !aGrfDlg.Execute() )
1829 // memorize selected filter
1830 aGrfName = aGrfDlg.GetPath();
1832 Graphic aGraphic;
1833 if( !aGrfDlg.GetGraphic(aGraphic) )
1835 aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
1836 bSucc = true;
1840 if(bSucc)
1842 aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit));
1844 sal_uInt16 nMask = 1;
1845 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1847 if(nActNumLvl & nMask)
1849 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1850 aNumFmt.SetCharFormatName(m_sNumCharFmtName);
1851 aNumFmt.SetGraphic(aGrfName);
1853 // set size for a later comparison
1854 const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
1855 // initiate asynchronous loading
1856 sal_Int16 eOrient = aNumFmt.GetVertOrient();
1857 aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient );
1858 aInitSize[i] = aNumFmt.GetGraphicSize();
1860 pActNum->SetLevel(i, aNumFmt);
1862 nMask <<= 1;
1864 m_xRatioCB->set_sensitive(true);
1865 m_xWidthFT->set_sensitive(true);
1866 m_xHeightFT->set_sensitive(true);
1867 m_xWidthMF->set_sensitive(true);
1868 m_xHeightMF->set_sensitive(true);
1869 SetMetricValue(*m_xWidthMF, aSize.Width(), eCoreUnit);
1870 SetMetricValue(*m_xHeightMF, aSize.Height(), eCoreUnit);
1871 m_xOrientFT->set_sensitive(true);
1872 m_xOrientLB->set_sensitive(true);
1873 SetModified();
1874 //needed due to asynchronous loading of graphics in the SvxBrushItem
1875 aInvalidateTimer.Start();
1879 IMPL_LINK_NOARG(SvxNumOptionsTabPage, PopupActivateHdl_Impl, weld::ToggleButton&, void)
1881 if (!m_xGalleryMenu)
1883 m_xGalleryMenu = m_xBuilder->weld_menu("gallerysubmenu");
1884 weld::WaitObject aWait(GetFrameWeld());
1886 if (GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames))
1888 GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS);
1890 Graphic aGraphic;
1891 OUString sGrfName;
1892 ScopedVclPtrInstance< VirtualDevice > pVD;
1893 size_t i = 0;
1894 for (const auto & grfName : aGrfNames)
1896 sGrfName = grfName;
1897 OUString sItemId = "gallery" + OUString::number(i);
1898 INetURLObject aObj(sGrfName);
1899 if(aObj.GetProtocol() == INetProtocol::File)
1900 sGrfName = aObj.PathToFileName();
1901 if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, i, &aGraphic))
1903 BitmapEx aBitmap(aGraphic.GetBitmapEx());
1904 Size aSize(aBitmap.GetSizePixel());
1905 if(aSize.Width() > MAX_BMP_WIDTH ||
1906 aSize.Height() > MAX_BMP_HEIGHT)
1908 bool bWidth = aSize.Width() > aSize.Height();
1909 double nScale = bWidth ?
1910 double(MAX_BMP_WIDTH) / static_cast<double>(aSize.Width()):
1911 double(MAX_BMP_HEIGHT) / static_cast<double>(aSize.Height());
1912 aBitmap.Scale(nScale, nScale);
1914 pVD->SetOutputSizePixel(aBitmap.GetSizePixel(), false);
1915 pVD->DrawBitmapEx(Point(), aBitmap);
1916 m_xGalleryMenu->append(sItemId, sGrfName, *pVD);
1918 else
1920 m_xGalleryMenu->append(sItemId, sGrfName);
1922 ++i;
1924 GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS);
1929 IMPL_LINK_NOARG(SvxNumOptionsTabPage, BulletHdl_Impl, weld::Button&, void)
1931 SvxCharacterMap aMap(GetFrameWeld(), nullptr, nullptr);
1933 sal_uInt16 nMask = 1;
1934 const vcl::Font* pFmtFont = nullptr;
1935 bool bSameBullet = true;
1936 sal_Unicode cBullet = 0;
1937 bool bFirst = true;
1938 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1940 if(nActNumLvl & nMask)
1942 const SvxNumberFormat& rCurFmt = pActNum->GetLevel(i);
1943 if(bFirst)
1945 cBullet = rCurFmt.GetBulletChar();
1947 else if(rCurFmt.GetBulletChar() != cBullet )
1949 bSameBullet = false;
1950 break;
1952 if(!pFmtFont)
1953 pFmtFont = rCurFmt.GetBulletFont();
1954 bFirst = false;
1956 nMask <<= 1;
1960 if (pFmtFont)
1961 aMap.SetCharFont(*pFmtFont);
1962 else
1963 aMap.SetCharFont(aActBulletFont);
1964 if (bSameBullet)
1965 aMap.SetChar(cBullet);
1966 if (aMap.run() == RET_OK)
1968 // change Font Numrules
1969 aActBulletFont = aMap.GetCharFont();
1971 sal_uInt16 _nMask = 1;
1972 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1974 if(nActNumLvl & _nMask)
1976 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1977 aNumFmt.SetBulletFont(&aActBulletFont);
1978 aNumFmt.SetBulletChar( static_cast<sal_Unicode>(aMap.GetChar()) );
1979 pActNum->SetLevel(i, aNumFmt);
1981 _nMask <<= 1;
1984 SetModified();
1988 IMPL_LINK( SvxNumOptionsTabPage, SizeHdl_Impl, weld::MetricSpinButton&, rField, void)
1990 bool bWidth = &rField == m_xWidthMF.get();
1991 bLastWidthModified = bWidth;
1992 bool bRatio = m_xRatioCB->get_active();
1993 long nWidthVal = static_cast<long>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::MM_100TH)));
1994 long nHeightVal = static_cast<long>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FieldUnit::MM_100TH)));
1995 nWidthVal = OutputDevice::LogicToLogic( nWidthVal ,
1996 MapUnit::Map100thMM, eCoreUnit );
1997 nHeightVal = OutputDevice::LogicToLogic( nHeightVal,
1998 MapUnit::Map100thMM, eCoreUnit);
1999 double fSizeRatio;
2001 bool bRepaint = false;
2002 sal_uInt16 nMask = 1;
2003 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2005 if(nActNumLvl & nMask)
2007 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2008 if(SVX_NUM_BITMAP == (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
2010 Size aSize(aNumFmt.GetGraphicSize() );
2011 Size aSaveSize(aSize);
2013 if (aInitSize[i].Height())
2014 fSizeRatio = static_cast<double>(aInitSize[i].Width()) / static_cast<double>(aInitSize[i].Height());
2015 else
2016 fSizeRatio = double(1);
2018 if(bWidth)
2020 long nDelta = nWidthVal - aInitSize[i].Width();
2021 aSize.setWidth( nWidthVal );
2022 if (bRatio)
2024 aSize.setHeight( aInitSize[i].Height() + static_cast<long>(static_cast<double>(nDelta) / fSizeRatio) );
2025 m_xHeightMF->set_value(m_xHeightMF->normalize(
2026 OutputDevice::LogicToLogic( aSize.Height(), eCoreUnit, MapUnit::Map100thMM )),
2027 FieldUnit::MM_100TH);
2030 else
2032 long nDelta = nHeightVal - aInitSize[i].Height();
2033 aSize.setHeight( nHeightVal );
2034 if (bRatio)
2036 aSize.setWidth( aInitSize[i].Width() + static_cast<long>(static_cast<double>(nDelta) * fSizeRatio) );
2037 m_xWidthMF->set_value(m_xWidthMF->normalize(
2038 OutputDevice::LogicToLogic( aSize.Width(), eCoreUnit, MapUnit::Map100thMM )),
2039 FieldUnit::MM_100TH);
2042 const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
2043 sal_Int16 eOrient = aNumFmt.GetVertOrient();
2044 if(aSize != aSaveSize)
2045 bRepaint = true;
2046 aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient );
2047 pActNum->SetLevel(i, aNumFmt);
2050 nMask <<= 1;
2052 SetModified(bRepaint);
2055 IMPL_LINK(SvxNumOptionsTabPage, RatioHdl_Impl, weld::ToggleButton&, rBox, void)
2057 if (rBox.get_active())
2059 if (bLastWidthModified)
2060 SizeHdl_Impl(*m_xWidthMF);
2061 else
2062 SizeHdl_Impl(*m_xHeightMF);
2066 IMPL_LINK_NOARG(SvxNumOptionsTabPage, CharFmtHdl_Impl, weld::ComboBox&, void)
2068 bAutomaticCharStyles = false;
2069 sal_Int32 nEntryPos = m_xCharFmtLB->get_active();
2070 OUString sEntry = m_xCharFmtLB->get_active_text();
2071 sal_uInt16 nMask = 1;
2072 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2074 if(nActNumLvl & nMask)
2076 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2077 if( 0 == nEntryPos )
2078 aNumFmt.SetCharFormatName("");
2079 else
2081 if(SVX_NUM_BITMAP != (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
2082 aNumFmt.SetCharFormatName(sEntry);
2084 pActNum->SetLevel(i, aNumFmt);
2086 nMask <<= 1;
2088 SetModified(false);
2091 IMPL_LINK_NOARG(SvxNumOptionsTabPage, EditListBoxHdl_Impl, weld::ComboBox&, void)
2093 EditModifyHdl_Impl(nullptr);
2096 IMPL_LINK(SvxNumOptionsTabPage, EditModifyHdl_Impl, weld::Entry&, rEdit, void)
2098 EditModifyHdl_Impl(&rEdit);
2101 IMPL_LINK(SvxNumOptionsTabPage, SpinModifyHdl_Impl, weld::SpinButton&, rSpinButton, void)
2103 EditModifyHdl_Impl(&rSpinButton);
2106 void SvxNumOptionsTabPage::EditModifyHdl_Impl(const weld::Entry* pEdit)
2108 bool bPrefix = pEdit == m_xPrefixED.get();
2109 bool bSuffix = pEdit == m_xSuffixED.get();
2110 bool bStart = pEdit == m_xStartED.get();
2111 sal_uInt16 nMask = 1;
2112 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2114 if(nActNumLvl & nMask)
2116 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2117 if(bPrefix)
2118 aNumFmt.SetPrefix(m_xPrefixED->get_text());
2119 else if(bSuffix)
2120 aNumFmt.SetSuffix(m_xSuffixED->get_text());
2121 else if(bStart)
2122 aNumFmt.SetStart(m_xStartED->get_value());
2123 pActNum->SetLevel(i, aNumFmt);
2125 nMask <<= 1;
2127 SetModified();
2130 static long lcl_DrawGraphic(VirtualDevice* pVDev, const SvxNumberFormat &rFmt, long nXStart,
2131 long nYMiddle, long nDivision)
2133 const SvxBrushItem* pBrushItem = rFmt.GetBrush();
2134 long nRet = 0;
2135 if(pBrushItem)
2137 const Graphic* pGrf = pBrushItem->GetGraphic();
2138 if(pGrf)
2140 Size aGSize( rFmt.GetGraphicSize() );
2141 aGSize.setWidth( aGSize.Width() / nDivision );
2142 nRet = aGSize.Width();
2143 aGSize.setHeight( aGSize.Height() / nDivision );
2144 pGrf->Draw( pVDev, Point(nXStart,nYMiddle - ( aGSize.Height() / 2) ),
2145 pVDev->PixelToLogic( aGSize ) );
2148 return nRet;
2152 static long lcl_DrawBullet(VirtualDevice* pVDev,
2153 const SvxNumberFormat& rFmt, long nXStart,
2154 long nYStart, const Size& rSize)
2156 vcl::Font aTmpFont(pVDev->GetFont());
2158 // via Uno it's possible that no font has been set!
2159 vcl::Font aFont(rFmt.GetBulletFont() ? *rFmt.GetBulletFont() : aTmpFont);
2160 Size aTmpSize(rSize);
2161 aTmpSize.setWidth( aTmpSize.Width() * ( rFmt.GetBulletRelSize()) );
2162 aTmpSize.setWidth( aTmpSize.Width() / 100 ) ;
2163 aTmpSize.setHeight( aTmpSize.Height() * ( rFmt.GetBulletRelSize()) );
2164 aTmpSize.setHeight( aTmpSize.Height() / 100 ) ;
2165 // in case of a height of zero it is drawn in original height
2166 if(!aTmpSize.Height())
2167 aTmpSize.setHeight( 1 );
2168 aFont.SetFontSize(aTmpSize);
2169 aFont.SetTransparent(true);
2170 Color aBulletColor = rFmt.GetBulletColor();
2171 if(aBulletColor == COL_AUTO)
2172 aBulletColor = pVDev->GetFillColor().IsDark() ? COL_WHITE : COL_BLACK;
2173 else if(aBulletColor == pVDev->GetFillColor())
2174 aBulletColor.Invert();
2175 aFont.SetColor(aBulletColor);
2176 pVDev->SetFont( aFont );
2177 OUString aText(rFmt.GetBulletChar());
2178 long nY = nYStart;
2179 nY -= ((aTmpSize.Height() - rSize.Height())/ 2);
2180 pVDev->DrawText( Point(nXStart, nY), aText );
2181 long nRet = pVDev->GetTextWidth(aText);
2183 pVDev->SetFont(aTmpFont);
2184 return nRet;
2187 SvxNumberingPreview::SvxNumberingPreview()
2188 : pActNum(nullptr)
2189 , bPosition(false)
2190 , nActLevel(SAL_MAX_UINT16)
2194 // paint preview of numeration
2195 void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& /*rRect*/)
2197 Size aSize(rRenderContext.PixelToLogic(GetOutputSizePixel()));
2199 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
2200 const Color aBackColor = rStyleSettings.GetFieldColor();
2201 const Color aTextColor = rStyleSettings.GetFieldTextColor();
2203 ScopedVclPtrInstance<VirtualDevice> pVDev(rRenderContext);
2204 pVDev->EnableRTL(rRenderContext.IsRTLEnabled());
2205 pVDev->SetMapMode(rRenderContext.GetMapMode());
2206 pVDev->SetOutputSize(aSize);
2208 Color aLineColor(COL_LIGHTGRAY);
2209 if (aLineColor == aBackColor)
2210 aLineColor.Invert();
2211 pVDev->SetLineColor(aLineColor);
2212 pVDev->SetFillColor(aBackColor);
2214 if (pActNum)
2216 long nWidthRelation = 30; // chapter dialog
2218 // height per level
2219 long nXStep = aSize.Width() / (3 * pActNum->GetLevelCount());
2220 if (pActNum->GetLevelCount() < 10)
2221 nXStep /= 2;
2222 long nYStart = 4;
2223 // the whole height mustn't be used for a single level
2224 long nYStep = (aSize.Height() - 6)/ (pActNum->GetLevelCount() > 1 ? pActNum->GetLevelCount() : 5);
2226 aStdFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, MsLangId::getSystemLanguage(), GetDefaultFontFlags::OnlyOne);
2227 aStdFont.SetColor(aTextColor);
2228 aStdFont.SetFillColor(aBackColor);
2230 long nFontHeight = nYStep * 6 / 10;
2231 if (bPosition)
2232 nFontHeight = nYStep * 15 / 10;
2233 aStdFont.SetFontSize(Size( 0, nFontHeight ));
2235 SvxNodeNum aNum;
2236 sal_uInt16 nPreNum = pActNum->GetLevel(0).GetStart();
2238 if (bPosition)
2240 long nLineHeight = nFontHeight * 8 / 7;
2241 sal_uInt8 nStart = 0;
2242 while (!(nActLevel & (1<<nStart)))
2244 nStart++;
2246 if (nStart)
2247 nStart--;
2248 sal_uInt8 nEnd = std::min(sal_uInt8(nStart + 3), sal_uInt8(pActNum->GetLevelCount()));
2249 for (sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel)
2251 const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel);
2252 aNum.GetLevelVal()[nLevel] = rFmt.GetStart();
2254 long nXStart( 0 );
2255 short nTextOffset( 0 );
2256 long nNumberXPos( 0 );
2257 if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
2259 nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
2260 nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation;
2261 nNumberXPos = nXStart;
2262 long nFirstLineOffset = (-rFmt.GetFirstLineOffset()) / nWidthRelation;
2264 if (nFirstLineOffset <= nNumberXPos)
2265 nNumberXPos = nNumberXPos - nFirstLineOffset;
2266 else
2267 nNumberXPos = 0;
2268 // in draw this is valid
2269 if (nTextOffset < 0)
2270 nNumberXPos = nNumberXPos + nTextOffset;
2272 else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT)
2274 const long nTmpNumberXPos((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation);
2275 if (nTmpNumberXPos < 0)
2277 nNumberXPos = 0;
2279 else
2281 nNumberXPos = nTmpNumberXPos;
2285 long nBulletWidth = 0;
2286 if (SVX_NUM_BITMAP == (rFmt.GetNumberingType() &(~LINK_TOKEN)))
2288 long nYMiddle = nYStart + ( nFontHeight / 2 );
2289 nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawGraphic(pVDev.get(), rFmt, nNumberXPos, nYMiddle, nWidthRelation) : 0;
2291 else if (SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType())
2293 nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawBullet(pVDev.get(), rFmt, nNumberXPos, nYStart, aStdFont.GetFontSize()) : 0;
2295 else
2297 pVDev->SetFont(aStdFont);
2298 aNum.SetLevel(nLevel);
2299 if (pActNum->IsContinuousNumbering())
2300 aNum.GetLevelVal()[nLevel] = nPreNum;
2301 OUString aText(pActNum->MakeNumString( aNum ));
2302 vcl::Font aSaveFont = pVDev->GetFont();
2303 vcl::Font aColorFont(aSaveFont);
2304 Color aTmpBulletColor = rFmt.GetBulletColor();
2305 if (aTmpBulletColor == COL_AUTO)
2306 aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK;
2307 else if (aTmpBulletColor == aBackColor)
2308 aTmpBulletColor.Invert();
2309 aColorFont.SetColor(aTmpBulletColor);
2310 pVDev->SetFont(aColorFont);
2311 pVDev->DrawText(Point(nNumberXPos, nYStart), aText);
2312 pVDev->SetFont(aSaveFont);
2313 nBulletWidth = pVDev->GetTextWidth(aText);
2314 nPreNum++;
2316 if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT &&
2317 rFmt.GetLabelFollowedBy() == SvxNumberFormat::SPACE )
2319 pVDev->SetFont(aStdFont);
2320 OUString aText(' ');
2321 pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
2322 nBulletWidth = nBulletWidth + pVDev->GetTextWidth(aText);
2325 long nTextXPos( 0 );
2326 if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
2328 nTextXPos = nXStart;
2329 if (nTextOffset < 0)
2330 nTextXPos = nTextXPos + nTextOffset;
2331 if (nNumberXPos + nBulletWidth + nTextOffset > nTextXPos)
2332 nTextXPos = nNumberXPos + nBulletWidth + nTextOffset;
2334 else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT)
2336 switch (rFmt.GetLabelFollowedBy())
2338 case SvxNumberFormat::LISTTAB:
2340 nTextXPos = rFmt.GetListtabPos() / nWidthRelation;
2341 if (nTextXPos < nNumberXPos + nBulletWidth)
2343 nTextXPos = nNumberXPos + nBulletWidth;
2346 break;
2347 case SvxNumberFormat::SPACE:
2348 case SvxNumberFormat::NOTHING:
2349 case SvxNumberFormat::NEWLINE:
2351 nTextXPos = nNumberXPos + nBulletWidth;
2353 break;
2356 nXStart = rFmt.GetIndentAt() / nWidthRelation;
2359 ::tools::Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2));
2360 pVDev->SetFillColor(aBackColor);
2361 pVDev->DrawRect(aRect1);
2363 ::tools::Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2));
2364 pVDev->DrawRect(aRect2);
2365 nYStart += 2 * nLineHeight;
2368 else
2370 //#i5153# painting gray or black rectangles as 'normal' numbering text
2371 long nWidth = pVDev->GetTextWidth("Preview");
2372 long nTextHeight = pVDev->GetTextHeight();
2373 long nRectHeight = nTextHeight * 2 / 3;
2374 long nTopOffset = nTextHeight - nRectHeight;
2375 Color aBlackColor(COL_BLACK);
2376 if (aBlackColor == aBackColor)
2377 aBlackColor.Invert();
2379 for (sal_uInt16 nLevel = 0; nLevel < pActNum->GetLevelCount(); ++nLevel, nYStart = nYStart + nYStep)
2381 const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel);
2382 aNum.GetLevelVal()[ nLevel ] = rFmt.GetStart();
2383 long nXStart( 0 );
2384 pVDev->SetFillColor( aBackColor );
2386 if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
2388 nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
2390 else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT)
2392 const long nTmpXStart((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation);
2393 if (nTmpXStart < 0)
2395 nXStart = 0;
2397 else
2399 nXStart = nTmpXStart;
2402 nXStart /= 2;
2403 nXStart += 2;
2404 long nTextOffset = 2 * nXStep;
2405 if (SVX_NUM_BITMAP == (rFmt.GetNumberingType()&(~LINK_TOKEN)))
2407 if (rFmt.IsShowSymbol())
2409 long nYMiddle = nYStart + ( nFontHeight / 2 );
2410 nTextOffset = lcl_DrawGraphic(pVDev.get(), rFmt, nXStart, nYMiddle, nWidthRelation);
2411 nTextOffset = nTextOffset + nXStep;
2414 else if (SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType())
2416 if (rFmt.IsShowSymbol())
2418 nTextOffset = lcl_DrawBullet(pVDev.get(), rFmt, nXStart, nYStart, aStdFont.GetFontSize());
2419 nTextOffset = nTextOffset + nXStep;
2422 else
2424 vcl::Font aFont(aStdFont);
2425 Size aTmpSize(aStdFont.GetFontSize());
2426 if(pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE))
2428 aTmpSize.setWidth( aTmpSize.Width() * ( rFmt.GetBulletRelSize()) );
2429 aTmpSize.setWidth( aTmpSize.Width() / 100 ) ;
2430 aTmpSize.setHeight( aTmpSize.Height() * ( rFmt.GetBulletRelSize()) );
2431 aTmpSize.setHeight( aTmpSize.Height() / 100 ) ;
2433 if(!aTmpSize.Height())
2434 aTmpSize.setHeight( 1 );
2435 aFont.SetFontSize(aTmpSize);
2436 Color aTmpBulletColor = rFmt.GetBulletColor();
2437 if (aTmpBulletColor == COL_AUTO)
2438 aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK;
2439 else if (aTmpBulletColor == aBackColor)
2440 aTmpBulletColor.Invert();
2441 aFont.SetColor(aTmpBulletColor);
2442 pVDev->SetFont(aFont);
2443 aNum.SetLevel( nLevel );
2444 if (pActNum->IsContinuousNumbering())
2445 aNum.GetLevelVal()[nLevel] = nPreNum;
2446 OUString aText(pActNum->MakeNumString(aNum));
2447 long nY = nYStart;
2448 nY -= (pVDev->GetTextHeight() - nTextHeight - pVDev->GetFontMetric().GetDescent());
2449 pVDev->DrawText(Point(nXStart, nY), aText);
2450 nTextOffset = pVDev->GetTextWidth(aText);
2451 nTextOffset = nTextOffset + nXStep;
2452 nPreNum++;
2453 pVDev->SetFont(aStdFont);
2455 //#i5153# the selected rectangle(s) should be black
2456 if (0 != (nActLevel & (1<<nLevel)))
2458 pVDev->SetFillColor( aBlackColor );
2459 pVDev->SetLineColor( aBlackColor );
2461 else
2463 //#i5153# unselected levels are gray
2464 pVDev->SetFillColor( aLineColor );
2465 pVDev->SetLineColor( aLineColor );
2467 ::tools::Rectangle aRect1(Point(nXStart + nTextOffset, nYStart + nTopOffset), Size(nWidth, nRectHeight));
2468 pVDev->DrawRect(aRect1);
2472 rRenderContext.DrawOutDev(Point(), aSize, Point(), aSize, *pVDev);
2476 //See uiconfig/swriter/ui/outlinepositionpage.ui for effectively a duplicate
2477 //dialog to this one, except with a different preview window impl.
2478 //TODO, determine if SwNumPositionTabPage and SvxNumPositionTabPage can be
2479 //merged
2480 SvxNumPositionTabPage::SvxNumPositionTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
2481 : SfxTabPage(pPage, pController, "cui/ui/numberingpositionpage.ui", "NumberingPositionPage", &rSet)
2482 , m_pLevelHdlEvent(nullptr)
2483 , nActNumLvl(1)
2484 , nNumItemId(SID_ATTR_NUMBERING_RULE)
2485 , bModified(false)
2486 , bPreset(false)
2487 , bInInintControl(false)
2488 , bLabelAlignmentPosAndSpaceModeActive(false)
2489 , m_xLevelLB(m_xBuilder->weld_tree_view("levellb"))
2490 , m_xDistBorderFT(m_xBuilder->weld_label("indent"))
2491 , m_xDistBorderMF(m_xBuilder->weld_metric_spin_button("indentmf", FieldUnit::CM))
2492 , m_xRelativeCB(m_xBuilder->weld_check_button("relative"))
2493 , m_xIndentFT(m_xBuilder->weld_label("numberingwidth"))
2494 , m_xIndentMF(m_xBuilder->weld_metric_spin_button("numberingwidthmf", FieldUnit::CM))
2495 , m_xDistNumFT(m_xBuilder->weld_label("numdist"))
2496 , m_xDistNumMF(m_xBuilder->weld_metric_spin_button("numdistmf", FieldUnit::CM))
2497 , m_xAlignFT(m_xBuilder->weld_label("numalign"))
2498 , m_xAlignLB(m_xBuilder->weld_combo_box("numalignlb"))
2499 , m_xLabelFollowedByFT(m_xBuilder->weld_label("numfollowedby"))
2500 , m_xLabelFollowedByLB(m_xBuilder->weld_combo_box("numfollowedbylb"))
2501 , m_xListtabFT(m_xBuilder->weld_label("at"))
2502 , m_xListtabMF(m_xBuilder->weld_metric_spin_button("atmf", FieldUnit::CM))
2503 , m_xAlign2FT(m_xBuilder->weld_label("num2align"))
2504 , m_xAlign2LB(m_xBuilder->weld_combo_box("num2alignlb"))
2505 , m_xAlignedAtFT(m_xBuilder->weld_label("alignedat"))
2506 , m_xAlignedAtMF(m_xBuilder->weld_metric_spin_button("alignedatmf", FieldUnit::CM))
2507 , m_xIndentAtFT(m_xBuilder->weld_label("indentat"))
2508 , m_xIndentAtMF(m_xBuilder->weld_metric_spin_button("indentatmf", FieldUnit::CM))
2509 , m_xStandardPB(m_xBuilder->weld_button("standard"))
2510 , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN))
2512 SetExchangeSupport();
2514 m_xAlignedAtMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE);
2515 m_xListtabMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE);
2516 m_xIndentAtMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE);
2518 m_xRelativeCB->set_active(true);
2519 m_xAlignLB->connect_changed(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl));
2520 m_xAlign2LB->connect_changed(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl));
2521 for ( sal_Int32 i = 0; i < m_xAlignLB->get_count(); ++i )
2523 m_xAlign2LB->append_text(m_xAlignLB->get_text(i));
2526 Link<weld::MetricSpinButton&,void> aLk3 = LINK(this, SvxNumPositionTabPage, DistanceHdl_Impl);
2527 m_xDistBorderMF->connect_value_changed(aLk3);
2528 m_xDistNumMF->connect_value_changed(aLk3);
2529 m_xIndentMF->connect_value_changed(aLk3);
2531 m_xLabelFollowedByLB->connect_changed(LINK(this, SvxNumPositionTabPage, LabelFollowedByHdl_Impl));
2533 m_xListtabMF->connect_value_changed(LINK(this, SvxNumPositionTabPage, ListtabPosHdl_Impl));
2534 m_xAlignedAtMF->connect_value_changed(LINK(this, SvxNumPositionTabPage, AlignAtHdl_Impl));
2535 m_xIndentAtMF->connect_value_changed(LINK(this, SvxNumPositionTabPage, IndentAtHdl_Impl));
2537 m_xLevelLB->set_selection_mode(SelectionMode::Multiple);
2538 m_xLevelLB->connect_changed(LINK(this, SvxNumPositionTabPage, LevelHdl_Impl));
2539 m_xRelativeCB->connect_toggled(LINK(this, SvxNumPositionTabPage, RelativeHdl_Impl));
2540 m_xStandardPB->connect_clicked(LINK(this, SvxNumPositionTabPage, StandardHdl_Impl));
2542 m_xRelativeCB->set_active(bLastRelative);
2543 m_aPreviewWIN.SetPositionMode();
2544 eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
2547 SvxNumPositionTabPage::~SvxNumPositionTabPage()
2549 if (m_pLevelHdlEvent)
2551 Application::RemoveUserEvent(m_pLevelHdlEvent);
2552 m_pLevelHdlEvent = nullptr;
2554 m_xPreviewWIN.reset();
2557 /*-------------------------------------------------------*/
2559 void SvxNumPositionTabPage::InitControls()
2561 bInInintControl = true;
2562 const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive &&
2563 m_xRelativeCB->get_sensitive() && m_xRelativeCB->get_active();
2564 const bool bSingleSelection = m_xLevelLB->count_selected_rows() == 1 &&
2565 SAL_MAX_UINT16 != nActNumLvl;
2567 m_xDistBorderMF->set_sensitive( !bLabelAlignmentPosAndSpaceModeActive &&
2568 ( bSingleSelection || bRelative ) );
2569 m_xDistBorderFT->set_sensitive( !bLabelAlignmentPosAndSpaceModeActive &&
2570 ( bSingleSelection || bRelative ) );
2572 bool bSetDistEmpty = false;
2573 bool bSameDistBorderNum = !bLabelAlignmentPosAndSpaceModeActive;
2574 bool bSameDist = !bLabelAlignmentPosAndSpaceModeActive;
2575 bool bSameIndent = !bLabelAlignmentPosAndSpaceModeActive;
2576 bool bSameAdjust = true;
2578 bool bSameLabelFollowedBy = bLabelAlignmentPosAndSpaceModeActive;
2579 bool bSameListtab = bLabelAlignmentPosAndSpaceModeActive;
2580 bool bSameAlignAt = bLabelAlignmentPosAndSpaceModeActive;
2581 bool bSameIndentAt = bLabelAlignmentPosAndSpaceModeActive;
2583 const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
2584 sal_uInt16 nMask = 1;
2585 sal_uInt16 nLvl = SAL_MAX_UINT16;
2586 long nFirstBorderTextRelative = -1;
2587 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2589 aNumFmtArr[i] = &pActNum->GetLevel(i);
2590 if(nActNumLvl & nMask)
2592 if(SAL_MAX_UINT16 == nLvl)
2593 nLvl = i;
2595 if( i > nLvl)
2597 bSameAdjust &= aNumFmtArr[i]->GetNumAdjust() == aNumFmtArr[nLvl]->GetNumAdjust();
2598 if ( !bLabelAlignmentPosAndSpaceModeActive )
2600 if(bRelative)
2602 if(nFirstBorderTextRelative == -1)
2603 nFirstBorderTextRelative =
2604 (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
2605 aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
2606 else
2607 bSameDistBorderNum &= nFirstBorderTextRelative ==
2608 (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
2609 aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
2611 else
2612 bSameDistBorderNum &=
2613 aNumFmtArr[i]->GetAbsLSpace() - aNumFmtArr[i]->GetFirstLineOffset() ==
2614 aNumFmtArr[i - 1]->GetAbsLSpace() - aNumFmtArr[i - 1]->GetFirstLineOffset();
2616 bSameDist &= aNumFmtArr[i]->GetCharTextDistance() == aNumFmtArr[nLvl]->GetCharTextDistance();
2617 bSameIndent &= aNumFmtArr[i]->GetFirstLineOffset() == aNumFmtArr[nLvl]->GetFirstLineOffset();
2619 else
2621 bSameLabelFollowedBy &=
2622 aNumFmtArr[i]->GetLabelFollowedBy() == aNumFmtArr[nLvl]->GetLabelFollowedBy();
2623 bSameListtab &=
2624 aNumFmtArr[i]->GetListtabPos() == aNumFmtArr[nLvl]->GetListtabPos();
2625 bSameAlignAt &=
2626 ( ( aNumFmtArr[i]->GetIndentAt() + aNumFmtArr[i]->GetFirstLineIndent() )
2627 == ( aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent() ) );
2628 bSameIndentAt &=
2629 aNumFmtArr[i]->GetIndentAt() == aNumFmtArr[nLvl]->GetIndentAt();
2633 nMask <<= 1;
2636 if (SVX_MAX_NUM <= nLvl)
2638 OSL_ENSURE(false, "cannot happen.");
2639 return;
2642 if(bSameDistBorderNum)
2644 long nDistBorderNum;
2645 if(bRelative)
2647 nDistBorderNum = static_cast<long>(aNumFmtArr[nLvl]->GetAbsLSpace())+ aNumFmtArr[nLvl]->GetFirstLineOffset();
2648 if(nLvl)
2649 nDistBorderNum -= static_cast<long>(aNumFmtArr[nLvl - 1]->GetAbsLSpace())+ aNumFmtArr[nLvl - 1]->GetFirstLineOffset();
2651 else
2653 nDistBorderNum = static_cast<long>(aNumFmtArr[nLvl]->GetAbsLSpace())+ aNumFmtArr[nLvl]->GetFirstLineOffset();
2655 SetMetricValue(*m_xDistBorderMF, nDistBorderNum, eCoreUnit);
2657 else
2658 bSetDistEmpty = true;
2660 if(bSameDist)
2661 SetMetricValue(*m_xDistNumMF, aNumFmtArr[nLvl]->GetCharTextDistance(), eCoreUnit);
2662 else
2663 m_xDistNumMF->set_text("");
2664 if(bSameIndent)
2665 SetMetricValue(*m_xIndentMF, - aNumFmtArr[nLvl]->GetFirstLineOffset(), eCoreUnit);
2666 else
2667 m_xIndentMF->set_text("");
2669 if(bSameAdjust)
2671 sal_Int32 nPos = 1; // centered
2672 if(aNumFmtArr[nLvl]->GetNumAdjust() == SvxAdjust::Left)
2673 nPos = 0;
2674 else if(aNumFmtArr[nLvl]->GetNumAdjust() == SvxAdjust::Right)
2675 nPos = 2;
2676 m_xAlignLB->set_active(nPos);
2677 m_xAlign2LB->set_active(nPos);
2679 else
2681 m_xAlignLB->set_active(-1);
2682 m_xAlign2LB->set_active(-1);
2685 if ( bSameLabelFollowedBy )
2687 sal_Int32 nPos = 0; // LISTTAB
2688 if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::SPACE )
2690 nPos = 1;
2692 else if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING )
2694 nPos = 2;
2696 else if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NEWLINE )
2698 nPos = 3;
2700 m_xLabelFollowedByLB->set_active(nPos);
2702 else
2704 m_xLabelFollowedByLB->set_active(-1);
2707 if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
2709 m_xListtabFT->set_sensitive(true);
2710 m_xListtabMF->set_sensitive(true);
2711 if ( bSameListtab )
2713 SetMetricValue(*m_xListtabMF, aNumFmtArr[nLvl]->GetListtabPos(), eCoreUnit);
2715 else
2717 m_xListtabMF->set_text("");
2720 else
2722 m_xListtabFT->set_sensitive(false);
2723 m_xListtabMF->set_sensitive(false);
2724 m_xListtabMF->set_text("");
2727 if ( bSameAlignAt )
2729 SetMetricValue(*m_xAlignedAtMF,
2730 aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent(),
2731 eCoreUnit);
2733 else
2735 m_xAlignedAtMF->set_text("");
2738 if ( bSameIndentAt )
2740 SetMetricValue(*m_xIndentAtMF, aNumFmtArr[nLvl]->GetIndentAt(), eCoreUnit);
2742 else
2744 m_xIndentAtMF->set_text("");
2747 if ( bSetDistEmpty )
2748 m_xDistBorderMF->set_text("");
2750 bInInintControl = false;
2753 void SvxNumPositionTabPage::ActivatePage(const SfxItemSet& rSet)
2755 const SfxPoolItem* pItem;
2756 sal_uInt16 nTmpNumLvl = 1;
2757 const SfxItemSet* pExampleSet = GetDialogExampleSet();
2758 if(pExampleSet)
2760 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
2761 bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue();
2762 if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
2763 nTmpNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
2765 if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
2767 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
2769 bModified = (!pActNum->Get( 0 ) || bPreset);
2770 if(*pSaveNum != *pActNum ||
2771 nActNumLvl != nTmpNumLvl )
2773 *pActNum = *pSaveNum;
2774 nActNumLvl = nTmpNumLvl;
2775 sal_uInt16 nMask = 1;
2776 m_xLevelLB->unselect_all();
2777 if (nActNumLvl == SAL_MAX_UINT16)
2778 m_xLevelLB->select(pActNum->GetLevelCount());
2779 if (nActNumLvl != SAL_MAX_UINT16)
2780 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2782 if (nActNumLvl & nMask)
2783 m_xLevelLB->select(i);
2784 nMask <<= 1 ;
2786 m_xRelativeCB->set_sensitive(nActNumLvl != 1);
2788 InitPosAndSpaceMode();
2789 ShowControlsDependingOnPosAndSpaceMode();
2791 InitControls();
2793 m_aPreviewWIN.SetLevel(nActNumLvl);
2794 m_aPreviewWIN.Invalidate();
2797 DeactivateRC SvxNumPositionTabPage::DeactivatePage(SfxItemSet *_pSet)
2799 if(_pSet)
2801 if (m_xDistBorderMF->get_sensitive())
2802 DistanceHdl_Impl(*m_xDistBorderMF);
2803 DistanceHdl_Impl(*m_xIndentMF);
2804 FillItemSet(_pSet);
2806 return DeactivateRC::LeavePage;
2809 bool SvxNumPositionTabPage::FillItemSet( SfxItemSet* rSet )
2811 rSet->Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
2813 if(bModified && pActNum)
2815 *pSaveNum = *pActNum;
2816 rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ));
2817 rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, false));
2819 return bModified;
2822 void SvxNumPositionTabPage::Reset( const SfxItemSet* rSet )
2824 const SfxPoolItem* pItem;
2825 // in Draw the item exists as WhichId, in Writer only as SlotId
2826 SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
2827 if(eState != SfxItemState::SET)
2829 nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
2830 eState = rSet->GetItemState(nNumItemId, false, &pItem);
2832 if( eState != SfxItemState::SET )
2834 pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
2835 eState = SfxItemState::SET;
2839 DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
2840 pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
2842 // insert levels
2843 if (!m_xLevelLB->count_selected_rows())
2845 for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
2846 m_xLevelLB->append_text(OUString::number(i));
2847 if(pSaveNum->GetLevelCount() > 1)
2849 OUString sEntry = "1 - " + OUString::number( pSaveNum->GetLevelCount() );
2850 m_xLevelLB->append_text(sEntry);
2851 m_xLevelLB->select_text(sEntry);
2853 else
2854 m_xLevelLB->select(0);
2856 else
2857 m_xLevelLB->select(m_xLevelLB->count_selected_rows() - 1);
2858 sal_uInt16 nMask = 1;
2859 m_xLevelLB->unselect_all();
2860 if (nActNumLvl == SAL_MAX_UINT16)
2862 m_xLevelLB->select(pSaveNum->GetLevelCount());
2864 else
2866 for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
2868 if(nActNumLvl & nMask)
2869 m_xLevelLB->select(i);
2870 nMask <<= 1;
2874 if(!pActNum)
2875 pActNum.reset( new SvxNumRule(*pSaveNum) );
2876 else if(*pSaveNum != *pActNum)
2877 *pActNum = *pSaveNum;
2878 m_aPreviewWIN.SetNumRule(pActNum.get());
2880 InitPosAndSpaceMode();
2881 ShowControlsDependingOnPosAndSpaceMode();
2883 InitControls();
2884 bModified = false;
2887 void SvxNumPositionTabPage::InitPosAndSpaceMode()
2889 if ( pActNum == nullptr )
2891 SAL_WARN( "cui.tabpages",
2892 "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
2893 return;
2896 SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode =
2897 SvxNumberFormat::LABEL_ALIGNMENT;
2898 sal_uInt16 nMask = 1;
2899 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
2901 if(nActNumLvl & nMask)
2903 SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
2904 ePosAndSpaceMode = aNumFmt.GetPositionAndSpaceMode();
2905 if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2907 break;
2910 nMask <<= 1;
2913 bLabelAlignmentPosAndSpaceModeActive =
2914 ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT;
2917 void SvxNumPositionTabPage::ShowControlsDependingOnPosAndSpaceMode()
2919 m_xDistBorderFT->set_visible( !bLabelAlignmentPosAndSpaceModeActive );
2920 m_xDistBorderMF->set_visible( !bLabelAlignmentPosAndSpaceModeActive );
2921 m_xRelativeCB->set_visible( !bLabelAlignmentPosAndSpaceModeActive );
2922 m_xIndentFT->set_visible( !bLabelAlignmentPosAndSpaceModeActive );
2923 m_xIndentMF->set_visible( !bLabelAlignmentPosAndSpaceModeActive );
2924 m_xDistNumFT->set_visible( !bLabelAlignmentPosAndSpaceModeActive &&
2925 pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS) );
2926 m_xDistNumMF->set_visible( !bLabelAlignmentPosAndSpaceModeActive &&
2927 pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS));
2928 m_xAlignFT->set_visible( !bLabelAlignmentPosAndSpaceModeActive );
2929 m_xAlignLB->set_visible( !bLabelAlignmentPosAndSpaceModeActive );
2931 m_xLabelFollowedByFT->set_visible( bLabelAlignmentPosAndSpaceModeActive );
2932 m_xLabelFollowedByLB->set_visible( bLabelAlignmentPosAndSpaceModeActive );
2933 m_xListtabFT->set_visible( bLabelAlignmentPosAndSpaceModeActive );
2934 m_xListtabMF->set_visible( bLabelAlignmentPosAndSpaceModeActive );
2935 m_xAlign2FT->set_visible( bLabelAlignmentPosAndSpaceModeActive );
2936 m_xAlign2LB->set_visible( bLabelAlignmentPosAndSpaceModeActive );
2937 m_xAlignedAtFT->set_visible( bLabelAlignmentPosAndSpaceModeActive );
2938 m_xAlignedAtMF->set_visible( bLabelAlignmentPosAndSpaceModeActive );
2939 m_xIndentAtFT->set_visible( bLabelAlignmentPosAndSpaceModeActive );
2940 m_xIndentAtMF->set_visible( bLabelAlignmentPosAndSpaceModeActive );
2943 std::unique_ptr<SfxTabPage> SvxNumPositionTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
2944 const SfxItemSet* rAttrSet)
2946 return std::make_unique<SvxNumPositionTabPage>(pPage, pController, *rAttrSet);
2949 void SvxNumPositionTabPage::SetMetric(FieldUnit eMetric)
2951 if (eMetric == FieldUnit::MM)
2953 m_xDistBorderMF->set_digits(1);
2954 m_xDistNumMF->set_digits(1);
2955 m_xIndentMF->set_digits(1);
2956 m_xListtabMF->set_digits(1);
2957 m_xAlignedAtMF->set_digits(1);
2958 m_xIndentAtMF->set_digits(1);
2960 m_xDistBorderMF->set_unit(eMetric);
2961 m_xDistNumMF->set_unit(eMetric);
2962 m_xIndentMF->set_unit(eMetric);
2963 m_xListtabMF->set_unit(eMetric);
2964 m_xAlignedAtMF->set_unit(eMetric);
2965 m_xIndentAtMF->set_unit(eMetric);
2968 IMPL_LINK_NOARG(SvxNumPositionTabPage, EditModifyHdl_Impl, weld::ComboBox&, void)
2970 sal_uInt16 nMask = 1;
2971 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2973 if(nActNumLvl & nMask)
2975 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2977 const sal_Int32 nPos = m_xAlignLB->get_visible()
2978 ? m_xAlignLB->get_active()
2979 : m_xAlign2LB->get_active();
2980 SvxAdjust eAdjust = SvxAdjust::Center;
2981 if(nPos == 0)
2982 eAdjust = SvxAdjust::Left;
2983 else if(nPos == 2)
2984 eAdjust = SvxAdjust::Right;
2985 aNumFmt.SetNumAdjust( eAdjust );
2986 pActNum->SetLevel(i, aNumFmt);
2988 nMask <<= 1;
2990 SetModified();
2993 IMPL_LINK_NOARG(SvxNumPositionTabPage, LevelHdl_Impl, weld::TreeView&, void)
2995 if (m_pLevelHdlEvent)
2996 return;
2997 // tdf#127120 multiselection may be implemented by deselect follow by select so
2998 // fire off the handler to happen on next event loop and only process the
2999 // final state
3000 m_pLevelHdlEvent = Application::PostUserEvent(LINK(this, SvxNumPositionTabPage, LevelHdl));
3003 IMPL_LINK_NOARG(SvxNumPositionTabPage, LevelHdl, void*, void)
3005 m_pLevelHdlEvent = nullptr;
3007 sal_uInt16 nSaveNumLvl = nActNumLvl;
3008 nActNumLvl = 0;
3009 std::vector<int> aSelectedRows = m_xLevelLB->get_selected_rows();
3010 if (std::find(aSelectedRows.begin(), aSelectedRows.end(), pActNum->GetLevelCount()) != aSelectedRows.end() &&
3011 (aSelectedRows.size() == 1 || nSaveNumLvl != 0xffff))
3013 nActNumLvl = 0xFFFF;
3014 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
3015 m_xLevelLB->unselect(i);
3017 else if (!aSelectedRows.empty())
3019 sal_uInt16 nMask = 1;
3020 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
3022 if (std::find(aSelectedRows.begin(), aSelectedRows.end(), i) != aSelectedRows.end())
3023 nActNumLvl |= nMask;
3024 nMask <<= 1;
3026 m_xLevelLB->unselect(pActNum->GetLevelCount());
3028 else
3030 nActNumLvl = nSaveNumLvl;
3031 sal_uInt16 nMask = 1;
3032 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
3034 if(nActNumLvl & nMask)
3036 m_xLevelLB->select(i);
3037 break;
3039 nMask <<=1;
3042 m_xRelativeCB->set_sensitive(nActNumLvl != 1);
3043 SetModified();
3044 InitPosAndSpaceMode();
3045 ShowControlsDependingOnPosAndSpaceMode();
3046 InitControls();
3049 IMPL_LINK(SvxNumPositionTabPage, DistanceHdl_Impl, weld::MetricSpinButton&, rFld, void)
3051 if(bInInintControl)
3052 return;
3053 long nValue = GetCoreValue(rFld, eCoreUnit);
3054 sal_uInt16 nMask = 1;
3055 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3057 if(nActNumLvl & nMask)
3059 SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) );
3060 if (&rFld == m_xDistBorderMF.get())
3063 if (m_xRelativeCB->get_active())
3065 if(0 == i)
3067 auto const nTmp = aNumFmt.GetFirstLineOffset();
3068 aNumFmt.SetAbsLSpace( nValue - nTmp);
3070 else
3072 long nTmp = pActNum->GetLevel( i - 1 ).GetAbsLSpace() +
3073 pActNum->GetLevel( i - 1 ).GetFirstLineOffset() -
3074 pActNum->GetLevel( i ).GetFirstLineOffset();
3076 aNumFmt.SetAbsLSpace( nValue + nTmp);
3079 else
3081 aNumFmt.SetAbsLSpace( nValue - aNumFmt.GetFirstLineOffset());
3084 else if (&rFld == m_xDistNumMF.get())
3086 aNumFmt.SetCharTextDistance( static_cast<short>(nValue) );
3088 else if (&rFld == m_xIndentMF.get())
3090 // together with the FirstLineOffset the AbsLSpace must be changed, too
3091 long nDiff = nValue + aNumFmt.GetFirstLineOffset();
3092 auto const nAbsLSpace = aNumFmt.GetAbsLSpace();
3093 aNumFmt.SetAbsLSpace(nAbsLSpace + nDiff);
3094 aNumFmt.SetFirstLineOffset( -nValue );
3097 pActNum->SetLevel( i, aNumFmt );
3099 nMask <<= 1;
3102 SetModified();
3103 if (!m_xDistBorderMF->get_sensitive())
3105 m_xDistBorderMF->set_text("");
3109 IMPL_LINK(SvxNumPositionTabPage, RelativeHdl_Impl, weld::ToggleButton&, rBox, void)
3111 bool bOn = rBox.get_active();
3112 bool bSingleSelection = m_xLevelLB->count_selected_rows() == 1 && SAL_MAX_UINT16 != nActNumLvl;
3113 bool bSetValue = false;
3114 long nValue = 0;
3115 if(bOn || bSingleSelection)
3117 sal_uInt16 nMask = 1;
3118 bool bFirst = true;
3119 bSetValue = true;
3120 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3122 if(nActNumLvl & nMask)
3124 const SvxNumberFormat &rNumFmt = pActNum->GetLevel(i);
3125 if(bFirst)
3127 nValue = rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset();
3128 if(bOn && i)
3129 nValue -= (pActNum->GetLevel(i - 1).GetAbsLSpace() + pActNum->GetLevel(i - 1).GetFirstLineOffset());
3131 else
3132 bSetValue = nValue ==
3133 (rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset()) -
3134 (pActNum->GetLevel(i - 1).GetAbsLSpace() + pActNum->GetLevel(i - 1).GetFirstLineOffset());
3135 bFirst = false;
3137 nMask <<= 1;
3141 if(bSetValue)
3142 SetMetricValue(*m_xDistBorderMF, nValue, eCoreUnit);
3143 else
3144 m_xDistBorderMF->set_text("");
3145 m_xDistBorderMF->set_sensitive(bOn || bSingleSelection);
3146 m_xDistBorderFT->set_sensitive(bOn || bSingleSelection);
3147 bLastRelative = bOn;
3150 IMPL_LINK_NOARG(SvxNumPositionTabPage, LabelFollowedByHdl_Impl, weld::ComboBox&, void)
3152 // determine value to be set at the chosen list levels
3153 SvxNumberFormat::LabelFollowedBy eLabelFollowedBy = SvxNumberFormat::LISTTAB;
3155 const auto nPos = m_xLabelFollowedByLB->get_active();
3156 if ( nPos == 1 )
3158 eLabelFollowedBy = SvxNumberFormat::SPACE;
3160 else if ( nPos == 2 )
3162 eLabelFollowedBy = SvxNumberFormat::NOTHING;
3164 else if ( nPos == 3 )
3166 eLabelFollowedBy = SvxNumberFormat::NEWLINE;
3170 // set value at the chosen list levels
3171 bool bSameListtabPos = true;
3172 sal_uInt16 nFirstLvl = SAL_MAX_UINT16;
3173 sal_uInt16 nMask = 1;
3174 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3176 if ( nActNumLvl & nMask )
3178 SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3179 aNumFmt.SetLabelFollowedBy( eLabelFollowedBy );
3180 pActNum->SetLevel( i, aNumFmt );
3182 if ( nFirstLvl == SAL_MAX_UINT16 )
3184 nFirstLvl = i;
3186 else
3188 bSameListtabPos &= aNumFmt.GetListtabPos() ==
3189 pActNum->GetLevel( nFirstLvl ).GetListtabPos();
3192 nMask <<= 1;
3195 // enable/disable metric field for list tab stop position depending on
3196 // selected item following the list label.
3197 m_xListtabFT->set_sensitive( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
3198 m_xListtabMF->set_sensitive( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
3199 if ( bSameListtabPos && eLabelFollowedBy == SvxNumberFormat::LISTTAB )
3201 SetMetricValue(*m_xListtabMF, pActNum->GetLevel( nFirstLvl ).GetListtabPos(), eCoreUnit);
3203 else
3205 m_xListtabMF->set_text(OUString());
3208 SetModified();
3211 IMPL_LINK(SvxNumPositionTabPage, ListtabPosHdl_Impl, weld::MetricSpinButton&, rFld, void)
3213 // determine value to be set at the chosen list levels
3214 const long nValue = GetCoreValue(rFld, eCoreUnit);
3216 // set value at the chosen list levels
3217 sal_uInt16 nMask = 1;
3218 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3220 if ( nActNumLvl & nMask )
3222 SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3223 aNumFmt.SetListtabPos( nValue );
3224 pActNum->SetLevel( i, aNumFmt );
3226 nMask <<= 1;
3229 SetModified();
3232 IMPL_LINK(SvxNumPositionTabPage, AlignAtHdl_Impl, weld::MetricSpinButton&, rFld, void)
3234 // determine value to be set at the chosen list levels
3235 const long nValue = GetCoreValue(rFld, eCoreUnit);
3237 // set value at the chosen list levels
3238 sal_uInt16 nMask = 1;
3239 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3241 if ( nActNumLvl & nMask )
3243 SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3244 const long nFirstLineIndent = nValue - aNumFmt.GetIndentAt();
3245 aNumFmt.SetFirstLineIndent( nFirstLineIndent );
3246 pActNum->SetLevel( i, aNumFmt );
3248 nMask <<= 1;
3251 SetModified();
3254 IMPL_LINK(SvxNumPositionTabPage, IndentAtHdl_Impl, weld::MetricSpinButton&, rFld, void)
3256 // determine value to be set at the chosen list levels
3257 const long nValue = GetCoreValue(rFld, eCoreUnit);
3259 // set value at the chosen list levels
3260 sal_uInt16 nMask = 1;
3261 for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3263 if ( nActNumLvl & nMask )
3265 SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3266 const long nAlignedAt = aNumFmt.GetIndentAt() +
3267 aNumFmt.GetFirstLineIndent();
3268 aNumFmt.SetIndentAt( nValue );
3269 const long nNewFirstLineIndent = nAlignedAt - nValue;
3270 aNumFmt.SetFirstLineIndent( nNewFirstLineIndent );
3271 pActNum->SetLevel( i, aNumFmt );
3273 nMask <<= 1;
3276 SetModified();
3279 IMPL_LINK_NOARG(SvxNumPositionTabPage, StandardHdl_Impl, weld::Button&, void)
3281 sal_uInt16 nMask = 1;
3282 SvxNumRule aTmpNumRule( pActNum->GetFeatureFlags(),
3283 pActNum->GetLevelCount(),
3284 pActNum->IsContinuousNumbering(),
3285 SvxNumRuleType::NUMBERING,
3286 pActNum->GetLevel( 0 ).GetPositionAndSpaceMode() );
3287 for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3289 if(nActNumLvl & nMask)
3291 SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) );
3292 const SvxNumberFormat& aTempFmt(aTmpNumRule.GetLevel( i ));
3293 aNumFmt.SetPositionAndSpaceMode( aTempFmt.GetPositionAndSpaceMode() );
3294 if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
3296 aNumFmt.SetAbsLSpace( aTempFmt.GetAbsLSpace() );
3297 aNumFmt.SetCharTextDistance( aTempFmt.GetCharTextDistance() );
3298 aNumFmt.SetFirstLineOffset( aTempFmt.GetFirstLineOffset() );
3300 else if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
3302 aNumFmt.SetNumAdjust( aTempFmt.GetNumAdjust() );
3303 aNumFmt.SetLabelFollowedBy( aTempFmt.GetLabelFollowedBy() );
3304 aNumFmt.SetListtabPos( aTempFmt.GetListtabPos() );
3305 aNumFmt.SetFirstLineIndent( aTempFmt.GetFirstLineIndent() );
3306 aNumFmt.SetIndentAt( aTempFmt.GetIndentAt() );
3309 pActNum->SetLevel( i, aNumFmt );
3311 nMask <<= 1;
3314 InitControls();
3315 SetModified();
3318 void SvxNumPositionTabPage::SetModified()
3320 bModified = true;
3321 m_aPreviewWIN.SetLevel(nActNumLvl);
3322 m_aPreviewWIN.Invalidate();
3325 void SvxNumOptionsTabPage::SetModified(bool bRepaint)
3327 bModified = true;
3328 if (bRepaint)
3330 m_aPreviewWIN.SetLevel(nActNumLvl);
3331 m_aPreviewWIN.Invalidate();
3335 void SvxNumOptionsTabPage::PageCreated(const SfxAllItemSet& aSet)
3337 const SfxStringListItem* pListItem = aSet.GetItem<SfxStringListItem>(SID_CHAR_FMT_LIST_BOX, false);
3338 const SfxStringItem* pNumCharFmt = aSet.GetItem<SfxStringItem>(SID_NUM_CHAR_FMT, false);
3339 const SfxStringItem* pBulletCharFmt = aSet.GetItem<SfxStringItem>(SID_BULLET_CHAR_FMT, false);
3340 const SfxUInt16Item* pMetricItem = aSet.GetItem<SfxUInt16Item>(SID_METRIC_ITEM, false);
3342 if (pNumCharFmt &&pBulletCharFmt)
3343 SetCharFmts( pNumCharFmt->GetValue(),pBulletCharFmt->GetValue());
3345 if (pListItem)
3347 const std::vector<OUString> &aList = pListItem->GetList();
3348 sal_uInt32 nCount = aList.size();
3349 for(sal_uInt32 i = 0; i < nCount; i++)
3350 m_xCharFmtLB->append_text(aList[i]);
3352 if (pMetricItem)
3353 SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
3356 void SvxNumPositionTabPage::PageCreated(const SfxAllItemSet& aSet)
3358 const SfxUInt16Item* pMetricItem = aSet.GetItem<SfxUInt16Item>(SID_METRIC_ITEM, false);
3360 if (pMetricItem)
3361 SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
3364 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */