LibreOffice Module cui (master)  1
numpages.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <com/sun/star/text/HoriOrientation.hpp>
21 #include <com/sun/star/text/VertOrientation.hpp>
22 
23 #include <numpages.hxx>
24 #include <dialmgr.hxx>
25 #include <tools/mapunit.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>
53 #include <svx/svxids.hrc>
54 
55 #include <algorithm>
56 #include <memory>
57 #include <vector>
58 #include <sfx2/opengrf.hxx>
59 
60 #include <strings.hrc>
61 #include <svl/aeitem.hxx>
62 #include <svl/stritem.hxx>
63 #include <svl/slstitm.hxx>
64 #include <sfx2/filedlghelper.hxx>
66 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
67 #include <sal/log.hxx>
68 #include <vcl/cvtgrf.hxx>
69 #include <vcl/graphicfilter.hxx>
71 #include <tools/urlobj.hxx>
72 #include <osl/diagnose.h>
73 
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;
82 
83 #define SHOW_NUMBERING 0
84 #define SHOW_BULLET 1
85 #define SHOW_BITMAP 2
86 
87 #define MAX_BMP_WIDTH 16
88 #define MAX_BMP_HEIGHT 16
89 #define SEARCHPATH_DELIMITER u';'
90 #define SEARCHFILENAME_DELIMITER u'/'
91 
92 static bool bLastRelative = false;
93 
95 {
96  const PropertyValue* pValues = rLevelProps.getConstArray();
98  for(sal_Int32 j = 0; j < rLevelProps.getLength(); j++)
99  {
100  if ( pValues[j].Name == "NumberingType" )
101  {
102  sal_Int16 nTmp;
103  if (pValues[j].Value >>= nTmp)
104  pNew->nNumberType = static_cast<SvxNumType>(nTmp);
105  }
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;
116  }
117  return pNew;
118 }
119 
120 // the selection of bullets from the OpenSymbol
121 static const sal_Unicode aBulletTypes[] =
122 {
123  0x2022,
124  0x25cf,
125  0xe00c,
126  0xe00a,
127  0x2794,
128  0x27a2,
129  0x2717,
130  0x2714
131 };
132 
133 // Is one of the masked formats set?
134 static bool lcl_IsNumFmtSet(SvxNumRule const * pNum, sal_uInt16 nLevelMask)
135 {
136  bool bRet = false;
137  sal_uInt16 nMask = 1;
138  for( sal_uInt16 i = 0; i < SVX_MAX_NUM && !bRet; i++ )
139  {
140  if(nLevelMask & nMask)
141  bRet |= nullptr != pNum->Get( i );
142  nMask <<= 1 ;
143  }
144  return bRet;
145 }
146 
148 {
149  static vcl::Font aDefBulletFont = [&]()
150  {
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;
160 }
161 
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))
170 {
172  m_xExamplesVS->init(NumberingPageType::SINGLENUM);
173  m_xExamplesVS->SetSelectHdl(LINK(this, SvxSingleNumPickTabPage, NumSelectHdl_Impl));
174  m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxSingleNumPickTabPage, DoubleClickHdl_Impl));
175 
176  Reference<XDefaultNumberingProvider> xDefNum = SvxNumOptionsTabPageHelper::GetNumberingProvider();
177  if(xDefNum.is())
178  {
179  Sequence< Sequence< PropertyValue > > aNumberings;
181  try
182  {
183  aNumberings =
184  xDefNum->getDefaultContinuousNumberingLevels( rLocale );
185 
186 
187  sal_Int32 nLength = std::min<sal_Int32>(aNumberings.getLength(), NUM_VALUSET_COUNT);
188 
189  const Sequence<PropertyValue>* pValuesArr = aNumberings.getConstArray();
190  for(sal_Int32 i = 0; i < nLength; i++)
191  {
192  SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(pValuesArr[i]);
193  aNumSettingsArr.push_back(std::unique_ptr<SvxNumSettings_Impl>(pNew));
194  }
195  }
196  catch(const Exception&)
197  {
198  }
199  Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
200  m_xExamplesVS->SetNumberingSettings(aNumberings, xFormat, rLocale);
201  }
202 }
203 
205 {
206  m_xExamplesVSWin.reset();
207  m_xExamplesVS.reset();
208 }
209 
210 std::unique_ptr<SfxTabPage> SvxSingleNumPickTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
211  const SfxItemSet* rAttrSet)
212 {
213  return std::make_unique<SvxSingleNumPickTabPage>(pPage, pController, *rAttrSet);
214 }
215 
217 {
218  if( (bPreset || bModified) && pSaveNum)
219  {
220  *pSaveNum = *pActNum;
222  rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
223  }
224 
225  return bModified;
226 }
227 
229 {
230  const SfxPoolItem* pItem;
231  bPreset = false;
232  bool bIsPreset = false;
233  const SfxItemSet* pExampleSet = GetDialogExampleSet();
234  if(pExampleSet)
235  {
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();
240  }
241  if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
242  {
243  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
244  }
245  if(pActNum && *pSaveNum != *pActNum)
246  {
247  *pActNum = *pSaveNum;
248  m_xExamplesVS->SetNoSelection();
249  }
250 
251  if(pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset))
252  {
253  m_xExamplesVS->SelectItem(1);
254  NumSelectHdl_Impl(m_xExamplesVS.get());
255  bPreset = true;
256  }
257  bPreset |= bIsPreset;
258 
259  bModified = false;
260 }
261 
263 {
264  if(_pSet)
265  FillItemSet(_pSet);
266  return DeactivateRC::LeavePage;
267 }
268 
270 {
271  const SfxPoolItem* pItem;
272 
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)
276  {
277  nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
278  eState = rSet->GetItemState(nNumItemId, false, &pItem);
279 
280  if( eState != SfxItemState::SET )
281  {
282  pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
283  eState = SfxItemState::SET;
284  }
285  }
286  DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
287  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
288 
289  if(!pActNum)
290  pActNum.reset( new SvxNumRule(*pSaveNum) );
291  else if(*pSaveNum != *pActNum)
292  *pActNum = *pSaveNum;
293 }
294 
296 {
297  if(pActNum)
298  {
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;
309 
310  sal_uInt16 nMask = 1;
311  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
312  {
313  if(nActNumLvl & nMask)
314  {
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);
328  }
329  nMask <<= 1;
330  }
331  }
332 }
333 
335 {
336  NumSelectHdl_Impl(m_xExamplesVS.get());
337  weld::Button& rOk = GetDialogController()->GetOKButton();
338  rOk.clicked();
339 }
340 
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))
349 {
351  m_xExamplesVS->init(NumberingPageType::BULLET);
352  m_xExamplesVS->SetSelectHdl(LINK(this, SvxBulletPickTabPage, NumSelectHdl_Impl));
353  m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxBulletPickTabPage, DoubleClickHdl_Impl));
354 }
355 
357 {
358  m_xExamplesVSWin.reset();
359  m_xExamplesVS.reset();
360 }
361 
362 std::unique_ptr<SfxTabPage> SvxBulletPickTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
363  const SfxItemSet* rAttrSet)
364 {
365  return std::make_unique<SvxBulletPickTabPage>(pPage, pController, *rAttrSet);
366 }
367 
369 {
370  if( (bPreset || bModified) && pActNum)
371  {
372  *pSaveNum = *pActNum;
374  rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
375  }
376  return bModified;
377 }
378 
380 {
381  const SfxPoolItem* pItem;
382  bPreset = false;
383  bool bIsPreset = false;
384  const SfxItemSet* pExampleSet = GetDialogExampleSet();
385  if(pExampleSet)
386  {
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();
391  }
392  if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
393  {
394  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
395  }
396  if(pActNum && *pSaveNum != *pActNum)
397  {
398  *pActNum = *pSaveNum;
399  m_xExamplesVS->SetNoSelection();
400  }
401 
402  if(pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset))
403  {
404  m_xExamplesVS->SelectItem(1);
405  NumSelectHdl_Impl(m_xExamplesVS.get());
406  bPreset = true;
407  }
408  bPreset |= bIsPreset;
409  bModified = false;
410 }
411 
413 {
414  if(_pSet)
415  FillItemSet(_pSet);
416  return DeactivateRC::LeavePage;
417 }
418 
420 {
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)
425  {
426  nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
427  eState = rSet->GetItemState(nNumItemId, false, &pItem);
428 
429  if( eState != SfxItemState::SET )
430  {
431  pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
432  eState = SfxItemState::SET;
433  }
434 
435  }
436  DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
437  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
438 
439  if(!pActNum)
440  pActNum.reset( new SvxNumRule(*pSaveNum) );
441  else if(*pSaveNum != *pActNum)
442  *pActNum = *pSaveNum;
443 }
444 
446 {
447  if(pActNum)
448  {
449  bPreset = false;
450  bModified = true;
451  sal_Unicode cChar = aBulletTypes[m_xExamplesVS->GetSelectedItemId() - 1];
452  const vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont();
453 
454  sal_uInt16 nMask = 1;
455  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
456  {
457  if(nActNumLvl & nMask)
458  {
459  SvxNumberFormat aFmt(pActNum->GetLevel(i));
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);
469  }
470  nMask <<= 1;
471  }
472  }
473 }
474 
475 IMPL_LINK_NOARG(SvxBulletPickTabPage, DoubleClickHdl_Impl, SvtValueSet*, void)
476 {
477  NumSelectHdl_Impl(m_xExamplesVS.get());
478  weld::Button& rOk = GetDialogController()->GetOKButton();
479  rOk.clicked();
480 }
481 
483 {
484  const SfxStringItem* pBulletCharFmt = aSet.GetItem<SfxStringItem>(SID_BULLET_CHAR_FMT, false);
485 
486  if (pBulletCharFmt)
487  sBulletCharFormatName = pBulletCharFmt->GetValue();
488 }
489 
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))
498 {
500 
501  m_xExamplesVS->init(NumberingPageType::OUTLINE);
502  m_xExamplesVS->SetSelectHdl(LINK(this, SvxNumPickTabPage, NumSelectHdl_Impl));
503  m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxNumPickTabPage, DoubleClickHdl_Impl));
504 
505  Reference<XDefaultNumberingProvider> xDefNum = SvxNumOptionsTabPageHelper::GetNumberingProvider();
506  if(xDefNum.is())
507  {
508  Sequence<Reference<XIndexAccess> > aOutlineAccess;
510  try
511  {
512  aOutlineAccess = xDefNum->getDefaultOutlineNumberings( rLocale );
513 
514  for(sal_Int32 nItem = 0;
515  nItem < aOutlineAccess.getLength() && nItem < NUM_VALUSET_COUNT;
516  nItem++ )
517  {
518  SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[ nItem ];
519 
520  Reference<XIndexAccess> xLevel = aOutlineAccess.getConstArray()[nItem];
521  for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++)
522  {
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) );
528  }
529  }
530  }
531  catch(const Exception&)
532  {
533  }
534  Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY);
535  m_xExamplesVS->SetOutlineNumberingSettings(aOutlineAccess, xFormat, rLocale);
536  }
537 }
538 
540 {
541  m_xExamplesVSWin.reset();
542  m_xExamplesVS.reset();
543 }
544 
545 std::unique_ptr<SfxTabPage> SvxNumPickTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
546  const SfxItemSet* rAttrSet)
547 {
548  return std::make_unique<SvxNumPickTabPage>(pPage, pController, *rAttrSet);
549 }
550 
552 {
553  if( (bPreset || bModified) && pActNum)
554  {
555  *pSaveNum = *pActNum;
557  rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
558  }
559  return bModified;
560 }
561 
563 {
564  const SfxPoolItem* pItem;
565  bPreset = false;
566  bool bIsPreset = false;
567  const SfxItemSet* pExampleSet = GetDialogExampleSet();
568  if(pExampleSet)
569  {
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();
574  }
575  if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
576  {
577  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
578  }
579  if(pActNum && *pSaveNum != *pActNum)
580  {
581  *pActNum = *pSaveNum;
582  m_xExamplesVS->SetNoSelection();
583  }
584 
585  if(pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset))
586  {
587  m_xExamplesVS->SelectItem(1);
588  NumSelectHdl_Impl(m_xExamplesVS.get());
589  bPreset = true;
590  }
591  bPreset |= bIsPreset;
592  bModified = false;
593 }
594 
596 {
597  if(_pSet)
598  FillItemSet(_pSet);
599  return DeactivateRC::LeavePage;
600 }
601 
603 {
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)
608  {
609  nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
610  eState = rSet->GetItemState(nNumItemId, false, &pItem);
611 
612  if( eState != SfxItemState::SET )
613  {
614  pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
615  eState = SfxItemState::SET;
616  }
617 
618  }
619  DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
620  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
621 
622  if(!pActNum)
623  pActNum.reset( new SvxNumRule(*pSaveNum) );
624  else if(*pSaveNum != *pActNum)
625  *pActNum = *pSaveNum;
626 
627 }
628 
629 // all levels are changed here
630 IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, SvtValueSet*, void)
631 {
632  if(pActNum)
633  {
634  bPreset = false;
635  bModified = true;
636 
637  const FontList* pList = nullptr;
638 
639  SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[m_xExamplesVS->GetSelectedItemId() - 1];
640 
641  const vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont();
642  SvxNumSettings_Impl* pLevelSettings = nullptr;
643  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
644  {
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)
653  {
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())
659  {
660  //search for the font
661  if(!pList)
662  {
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;
668  }
669  if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) )
670  {
671  FontMetric aFontMetric = pList->Get(
672  pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE);
673  vcl::Font aFont(aFontMetric);
674  aFmt.SetBulletFont(&aFont);
675  }
676  else
677  {
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 );
687  }
688  }
689  else
690  aFmt.SetBulletFont( &rActBulletFont );
691 
692  aFmt.SetBulletChar( !pLevelSettings->sBulletChar.isEmpty()
693  ? pLevelSettings->sBulletChar[0]
694  : 0 );
695  aFmt.SetCharFormatName( sBulletCharFormatName );
696  aFmt.SetBulletRelSize(45);
697  }
698  else
699  {
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);
706  }
707  pActNum->SetLevel(i, aFmt);
708  }
709  }
710 }
711 
712 IMPL_LINK_NOARG(SvxNumPickTabPage, DoubleClickHdl_Impl, SvtValueSet*, void)
713 {
714  NumSelectHdl_Impl(m_xExamplesVS.get());
715  weld::Button& rOk = GetDialogController()->GetOKButton();
716  rOk.clicked();
717 }
718 
720 {
721  const SfxStringItem* pNumCharFmt = aSet.GetItem<SfxStringItem>(SID_NUM_CHAR_FMT, false);
722  const SfxStringItem* pBulletCharFmt = aSet.GetItem<SfxStringItem>(SID_BULLET_CHAR_FMT, false);
723 
724 
725  if (pNumCharFmt &&pBulletCharFmt)
726  SetCharFormatNames( pNumCharFmt->GetValue(),pBulletCharFmt->GetValue());
727 }
728 
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))
739 {
741 
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));
746 
747  eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
748 
749  // determine graphic name
751 
752  size_t i = 0;
753  for (auto & grfName : aGrfNames)
754  {
755  m_xExamplesVS->InsertItem( i + 1, i);
756 
757  INetURLObject aObj(grfName);
758  if(aObj.GetProtocol() == INetProtocol::File)
759  grfName = aObj.PathToFileName();
760 
761  m_xExamplesVS->SetItemText( i + 1, grfName );
762  ++i;
763  }
764 
765  if(aGrfNames.empty())
766  {
767  m_xErrorText->show();
768  }
769  else
770  {
771  m_xExamplesVS->Show();
772  m_xExamplesVS->SetFormat();
773  m_xExamplesVS->Invalidate();
774  }
775 }
776 
778 {
779  m_xExamplesVSWin.reset();
780  m_xExamplesVS.reset();
781 }
782 
783 std::unique_ptr<SfxTabPage> SvxBitmapPickTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
784  const SfxItemSet* rAttrSet)
785 {
786  return std::make_unique<SvxBitmapPickTabPage>(pPage, pController, *rAttrSet);
787 }
788 
790 {
791  const SfxPoolItem* pItem;
792  bPreset = false;
793  bool bIsPreset = false;
794  const SfxItemSet* pExampleSet = GetDialogExampleSet();
795  if(pExampleSet)
796  {
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();
801  }
802  if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
803  {
804  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
805  }
806  if(pActNum && *pSaveNum != *pActNum)
807  {
808  *pActNum = *pSaveNum;
809  m_xExamplesVS->SetNoSelection();
810  }
811 
812  if(!aGrfNames.empty() &&
813  (pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset)))
814  {
815  m_xExamplesVS->SelectItem(1);
816  NumSelectHdl_Impl(m_xExamplesVS.get());
817  bPreset = true;
818  }
819  bPreset |= bIsPreset;
820  bModified = false;
821 }
822 
824 {
825  if(_pSet)
826  FillItemSet(_pSet);
827  return DeactivateRC::LeavePage;
828 }
829 
831 {
832  if ( aGrfNames.empty() )
833  {
834  return false;
835  }
836  if( (bPreset || bModified) && pActNum)
837  {
838  *pSaveNum = *pActNum;
840  rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
841  }
842 
843  return bModified;
844 }
845 
847 {
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)
852  {
853  nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
854  eState = rSet->GetItemState(nNumItemId, false, &pItem);
855 
856  if( eState != SfxItemState::SET )
857  {
858  pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
859  eState = SfxItemState::SET;
860  }
861 
862  }
863  DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
864  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
865 
866  if(!pActNum)
867  pActNum.reset( new SvxNumRule(*pSaveNum) );
868  else if(*pSaveNum != *pActNum)
869  *pActNum = *pSaveNum;
870 }
871 
873 {
874  if(pActNum)
875  {
876  bPreset = false;
877  bModified = true;
878  sal_uInt16 nIdx = m_xExamplesVS->GetSelectedItemId() - 1;
879 
880  sal_uInt16 nMask = 1;
881  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
882  {
883  if(nActNumLvl & nMask)
884  {
885  SvxNumberFormat aFmt(pActNum->GetLevel(i));
887  aFmt.SetPrefix( "" );
888  aFmt.SetSuffix( "" );
889  aFmt.SetCharFormatName( "" );
890 
891  Graphic aGraphic;
893  {
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 );
899  }
900  else if(aGrfNames.size() > nIdx)
901  aFmt.SetGraphic( aGrfNames[nIdx] );
902  pActNum->SetLevel(i, aFmt);
903  }
904  nMask <<= 1;
905  }
906  }
907 }
908 
909 IMPL_LINK_NOARG(SvxBitmapPickTabPage, DoubleClickHdl_Impl, SvtValueSet*, void)
910 {
911  NumSelectHdl_Impl(m_xExamplesVS.get());
912  weld::Button& rOk = GetDialogController()->GetOKButton();
913  rOk.clicked();
914 }
915 
916 IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, void)
917 {
918  sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, GetFrameWeld());
919  aFileDialog.SetTitle(CuiResId(RID_SVXSTR_ADD_IMAGE));
920  if ( aFileDialog.Execute() != ERRCODE_NONE )
921  return;
922 
923  OUString aPath = SvtPathOptions().GetGalleryPath();
924  OUString aPathToken = aPath.getToken( 1 , SEARCHPATH_DELIMITER );
925 
926  OUString aUserImageURL = aFileDialog.GetPath();
927 
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);
934 
935  OUString aUserGalleryURL = aPathToken + "/" + aFileName;
936  INetURLObject aURL( aUserImageURL );
937  DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
938 
939  GraphicDescriptor aDescriptor(aURL);
940  if (aDescriptor.Detect())
941  {
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 ))
946  {
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 )
952  {
953  Graphic aGraphic;
954  GraphicConverter::Import( *pIn, aGraphic );
955 
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)
961  {
962  nPixelX = 30;
963  nPixelY = static_cast<long>(nPixelX*ratio);
964  }
965  if(nPixelY > 30)
966  {
967  nPixelY = 30;
968  nPixelX = static_cast<long>(nPixelY/ratio);
969  }
970 
971  aBitmap.Scale( Size( nPixelX, nPixelY ), BmpScaleFlag::Fast );
972  Graphic aScaledGraphic( aBitmap );
974 
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);
980 
981  sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( gURL.GetFileExtension() );
982  rFilter.ExportGraphic( aScaledGraphic, gURL , nFilterFormat, &aFilterData );
984 
985  aGrfNames.push_back(aUserGalleryURL);
986  size_t i = 0;
987  for (auto & grfName : aGrfNames)
988  {
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;
995  }
996 
997  if(aGrfNames.empty())
998  {
999  m_xErrorText->show();
1000  }
1001  else
1002  {
1003  m_xExamplesVS->Show();
1004  m_xExamplesVS->SetFormat();
1005  }
1006 
1007  }
1008  }
1009 
1010  }
1011 }
1012 
1013 // tabpage numbering options
1015  const SfxItemSet& rSet)
1016  : SfxTabPage(pPage, pController, "cui/ui/numberingoptionspage.ui", "NumberingOptionsPage", &rSet)
1017  , bLastWidthModified(false)
1018  , bModified(false)
1019  , bPreset(false)
1020  , bAutomaticCharStyles(true)
1021  , bHTMLMode(false)
1022  , nBullet(0xff)
1023  , nActNumLvl(1)
1024  , nNumItemId(SID_ATTR_NUMBERING_RULE)
1025  , m_xGrid(m_xBuilder->weld_widget("grid2"))
1026  , m_xLevelLB(m_xBuilder->weld_tree_view("levellb"))
1027  , m_xFmtLB(m_xBuilder->weld_combo_box("numfmtlb"))
1028  , m_xSeparatorFT(m_xBuilder->weld_label("separator"))
1029  , m_xPrefixFT(m_xBuilder->weld_label("prefixft"))
1030  , m_xPrefixED(m_xBuilder->weld_entry("prefix"))
1031  , m_xSuffixFT(m_xBuilder->weld_label("suffixft"))
1032  , m_xSuffixED(m_xBuilder->weld_entry("suffix"))
1033  , m_xCharFmtFT(m_xBuilder->weld_label("charstyleft"))
1034  , m_xCharFmtLB(m_xBuilder->weld_combo_box("charstyle"))
1035  , m_xBulColorFT(m_xBuilder->weld_label("colorft"))
1036  , m_xBulColLB(new ColorListBox(m_xBuilder->weld_menu_button("color"), pController->getDialog()))
1037  , m_xBulRelSizeFT(m_xBuilder->weld_label("relsizeft"))
1038  , m_xBulRelSizeMF(m_xBuilder->weld_metric_spin_button("relsize", FieldUnit::PERCENT))
1039  , m_xAllLevelFT(m_xBuilder->weld_label("sublevelsft"))
1040  , m_xAllLevelNF(m_xBuilder->weld_spin_button("sublevels"))
1041  , m_xStartFT(m_xBuilder->weld_label("startatft"))
1042  , m_xStartED(m_xBuilder->weld_spin_button("startat"))
1043  , m_xBulletFT(m_xBuilder->weld_label("bulletft"))
1044  , m_xBulletPB(m_xBuilder->weld_button("bullet"))
1045  , m_xBitmapFT(m_xBuilder->weld_label("bitmapft"))
1046  , m_xBitmapMB(m_xBuilder->weld_menu_button("bitmap"))
1047  , m_xWidthFT(m_xBuilder->weld_label("widthft"))
1048  , m_xWidthMF(m_xBuilder->weld_metric_spin_button("widthmf", FieldUnit::CM))
1049  , m_xHeightFT(m_xBuilder->weld_label("heightft"))
1050  , m_xHeightMF(m_xBuilder->weld_metric_spin_button("heightmf", FieldUnit::CM))
1051  , m_xRatioCB(m_xBuilder->weld_check_button("keepratio"))
1052  , m_xOrientFT(m_xBuilder->weld_label("orientft"))
1053  , m_xOrientLB(m_xBuilder->weld_combo_box("orientlb"))
1054  , m_xAllLevelsFrame(m_xBuilder->weld_widget("levelsframe"))
1055  , m_xSameLevelCB(m_xBuilder->weld_check_button("allsame"))
1056  , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN))
1057 {
1058  m_xBulColLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1059  m_xBulRelSizeMF->set_min(SVX_NUM_REL_SIZE_MIN, FieldUnit::PERCENT);
1060  m_xBulRelSizeMF->set_increments(5, 50, FieldUnit::PERCENT);
1063 
1064  m_xBulletPB->connect_clicked(LINK(this, SvxNumOptionsTabPage, BulletHdl_Impl));
1065  m_xFmtLB->connect_changed(LINK(this, SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl));
1066  m_xBitmapMB->connect_selected(LINK(this, SvxNumOptionsTabPage, GraphicHdl_Impl));
1067  m_xBitmapMB->connect_toggled(LINK(this, SvxNumOptionsTabPage, PopupActivateHdl_Impl));
1068  m_xLevelLB->set_selection_mode(SelectionMode::Multiple);
1069  m_xLevelLB->connect_changed(LINK(this, SvxNumOptionsTabPage, LevelHdl_Impl));
1070  m_xCharFmtLB->connect_changed(LINK(this, SvxNumOptionsTabPage, CharFmtHdl_Impl));
1071  m_xWidthMF->connect_value_changed(LINK(this, SvxNumOptionsTabPage, SizeHdl_Impl));
1072  m_xHeightMF->connect_value_changed(LINK(this, SvxNumOptionsTabPage, SizeHdl_Impl));
1073  m_xRatioCB->connect_toggled(LINK(this, SvxNumOptionsTabPage, RatioHdl_Impl));
1074  m_xStartED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1075  m_xPrefixED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1076  m_xSuffixED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl));
1077  m_xAllLevelNF->connect_value_changed(LINK(this,SvxNumOptionsTabPage, AllLevelHdl_Impl));
1078  m_xOrientLB->connect_changed(LINK(this, SvxNumOptionsTabPage, OrientHdl_Impl));
1079  m_xSameLevelCB->connect_toggled(LINK(this, SvxNumOptionsTabPage, SameLevelHdl_Impl));
1080  m_xBulRelSizeMF->connect_value_changed(LINK(this,SvxNumOptionsTabPage, BulRelSizeHdl_Impl));
1081  m_xBulColLB->SetSelectHdl(LINK(this, SvxNumOptionsTabPage, BulColorHdl_Impl));
1082  aInvalidateTimer.SetInvokeHandler(LINK(this, SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl));
1084 
1085  eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
1086 
1087  // Fill ListBox with predefined / translated numbering types.
1088  sal_uInt32 nCount = SvxNumberingTypeTable::Count();
1089  for (sal_uInt32 i = 0; i < nCount; ++i)
1090  {
1092  }
1093 
1094  // Get advanced numbering types from the component.
1095  // Watch out for the ugly
1096  // 136 == 0x88 == SVX_NUM_BITMAP|0x80 == SVX_NUM_BITMAP|LINK_TOKEN
1097  // to not remove that.
1099 
1100  m_xFmtLB->set_active(0);
1101 
1102  m_xCharFmtLB->set_size_request(m_xCharFmtLB->get_approximate_digit_width() * 10, -1);
1103  Size aSize(m_xGrid->get_preferred_size());
1104  m_xGrid->set_size_request(aSize.Width(), -1);
1105 }
1106 
1108 {
1109  m_xPreviewWIN.reset();
1110  m_xBulColLB.reset();
1111  pActNum.reset();
1112  pSaveNum.reset();
1113 }
1114 
1116 {
1117  if(eMetric == FieldUnit::MM)
1118  {
1119  m_xWidthMF->set_digits(1);
1120  m_xHeightMF->set_digits(1);
1121  }
1122  m_xWidthMF->set_unit(eMetric);
1123  m_xHeightMF->set_unit(eMetric);
1124 }
1125 
1126 std::unique_ptr<SfxTabPage> SvxNumOptionsTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1127  const SfxItemSet* rAttrSet)
1128 {
1129  return std::make_unique<SvxNumOptionsTabPage>(pPage, pController, *rAttrSet);
1130 };
1131 
1133 {
1134  const SfxPoolItem* pItem;
1135  const SfxItemSet* pExampleSet = GetDialogExampleSet();
1136  sal_uInt16 nTmpNumLvl = 1;
1137  if(pExampleSet)
1138  {
1139  if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
1140  bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1141  if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
1142  nTmpNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1143  }
1144  if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
1145  {
1146  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
1147  }
1148 
1149  bModified = (!pActNum->Get( 0 ) || bPreset);
1150  if(*pActNum != *pSaveNum ||
1151  nActNumLvl != nTmpNumLvl)
1152  {
1153  nActNumLvl = nTmpNumLvl;
1154  sal_uInt16 nMask = 1;
1155  if (nActNumLvl == SAL_MAX_UINT16)
1156  m_xLevelLB->select(pActNum->GetLevelCount());
1157  if(nActNumLvl != SAL_MAX_UINT16)
1158  {
1159  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1160  {
1161  if(nActNumLvl & nMask)
1162  m_xLevelLB->select(i);
1163  nMask <<= 1 ;
1164  }
1165  }
1166  *pActNum = *pSaveNum;
1167 
1168  InitControls();
1169  }
1170 }
1171 
1173 {
1174  if(_pSet)
1175  FillItemSet(_pSet);
1176  return DeactivateRC::LeavePage;
1177 }
1178 
1180 {
1181  rSet->Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
1182  if(bModified && pActNum)
1183  {
1184  *pSaveNum = *pActNum;
1186  rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, false));
1187  }
1188  return bModified;
1189 };
1190 
1192 {
1193  const SfxPoolItem* pItem;
1194  // in Draw the item exists as WhichId, in Writer only as SlotId
1195  SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
1196  if(eState != SfxItemState::SET)
1197  {
1198  nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
1199  eState = rSet->GetItemState(nNumItemId, false, &pItem);
1200 
1201  if( eState != SfxItemState::SET )
1202  {
1203  pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
1204  eState = SfxItemState::SET;
1205  }
1206 
1207  }
1208  DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
1209  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
1210 
1211  // insert levels
1212  if (!m_xLevelLB->n_children())
1213  {
1214  for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
1215  m_xLevelLB->append_text(OUString::number(i));
1216  if(pSaveNum->GetLevelCount() > 1)
1217  {
1218  OUString sEntry = "1 - " + OUString::number( pSaveNum->GetLevelCount() );
1219  m_xLevelLB->append_text(sEntry);
1220  m_xLevelLB->select_text(sEntry);
1221  }
1222  else
1223  m_xLevelLB->select(0);
1224  }
1225  else
1226  m_xLevelLB->select(m_xLevelLB->n_children() - 1);
1227 
1228  sal_uInt16 nMask = 1;
1229  m_xLevelLB->unselect_all();
1230  if (nActNumLvl == SAL_MAX_UINT16)
1231  {
1232  m_xLevelLB->select( pSaveNum->GetLevelCount() );
1233  }
1234  else
1235  {
1236  for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
1237  {
1238  if(nActNumLvl & nMask)
1239  m_xLevelLB->select( i );
1240  nMask <<= 1 ;
1241  }
1242  }
1243 
1244  if(!pActNum)
1245  pActNum.reset( new SvxNumRule(*pSaveNum) );
1246  else if(*pSaveNum != *pActNum)
1247  *pActNum = *pSaveNum;
1249  m_xSameLevelCB->set_active(pActNum->IsContinuousNumbering());
1250 
1251  SfxObjectShell* pShell;
1252  if ( SfxItemState::SET == rSet->GetItemState( SID_HTML_MODE, false, &pItem )
1253  || ( nullptr != ( pShell = SfxObjectShell::Current()) &&
1254  nullptr != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
1255  {
1256  sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1257  bHTMLMode = 0 != (nHtmlMode&HTMLMODE_ON);
1258  }
1259 
1260  bool bCharFmt = pActNum->IsFeatureSupported(SvxNumRuleFlags::CHAR_STYLE);
1261  m_xCharFmtFT->set_visible(bCharFmt);
1262  m_xCharFmtLB->set_visible(bCharFmt);
1263 
1264  bool bContinuous = pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS);
1265 
1266  bool bAllLevel = bContinuous && !bHTMLMode;
1267  m_xAllLevelFT->set_visible(bAllLevel);
1268  m_xAllLevelNF->set_visible(bAllLevel);
1269 
1270  m_xAllLevelsFrame->set_visible(bContinuous);
1271 
1272  // again misusage: in Draw there is numeration only until the bitmap
1273  // without SVX_NUM_NUMBER_NONE
1274  //remove types that are unsupported by Draw/Impress
1275  if(!bContinuous)
1276  {
1277  sal_Int32 nFmtCount = m_xFmtLB->get_count();
1278  for(sal_Int32 i = nFmtCount; i; i--)
1279  {
1280  sal_uInt16 nEntryData = m_xFmtLB->get_id(i - 1).toUInt32();
1281  if(/*SVX_NUM_NUMBER_NONE == nEntryData ||*/
1282  (SVX_NUM_BITMAP|LINK_TOKEN) == nEntryData)
1283  m_xFmtLB->remove(i - 1);
1284  }
1285  }
1286  //one must be enabled
1287  if(!pActNum->IsFeatureSupported(SvxNumRuleFlags::ENABLE_LINKED_BMP))
1288  {
1289  auto nPos = m_xFmtLB->find_id(OUString::number(SVX_NUM_BITMAP|LINK_TOKEN));
1290  if (nPos != -1)
1291  m_xFmtLB->remove(nPos);
1292  }
1293  else if(!pActNum->IsFeatureSupported(SvxNumRuleFlags::ENABLE_EMBEDDED_BMP))
1294  {
1295  auto nPos = m_xFmtLB->find_id(OUString::number(SVX_NUM_BITMAP));
1296  if (nPos != -1)
1297  m_xFmtLB->remove(nPos);
1298  }
1299 
1300  // MegaHack: because of a not-fixable 'design mistake/error' in Impress
1301  // delete all kinds of numeric enumerations
1302  if(pActNum->IsFeatureSupported(SvxNumRuleFlags::NO_NUMBERS))
1303  {
1304  sal_Int32 nFmtCount = m_xFmtLB->get_count();
1305  for(sal_Int32 i = nFmtCount; i; i--)
1306  {
1307  sal_uInt16 nEntryData = m_xFmtLB->get_id(i - 1).toUInt32();
1308  if( /*nEntryData >= SVX_NUM_CHARS_UPPER_LETTER &&*/ nEntryData <= SVX_NUM_NUMBER_NONE)
1309  m_xFmtLB->remove(i - 1);
1310  }
1311  }
1312 
1313  InitControls();
1314  bModified = false;
1315 }
1316 
1318 {
1319  bool bShowBullet = true;
1320  bool bShowBitmap = true;
1321  bool bSameType = true;
1322  bool bSameStart = true;
1323  bool bSamePrefix = true;
1324  bool bSameSuffix = true;
1325  bool bAllLevel = true;
1326  bool bSameCharFmt = true;
1327  bool bSameVOrient = true;
1328  bool bSameSize = true;
1329  bool bSameBulColor = true;
1330  bool bSameBulRelSize= true;
1331 
1332  const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
1333  OUString sFirstCharFmt;
1334  sal_Int16 eFirstOrient = text::VertOrientation::NONE;
1335  Size aFirstSize(0,0);
1336  sal_uInt16 nMask = 1;
1337  sal_uInt16 nLvl = SAL_MAX_UINT16;
1338  sal_uInt16 nHighestLevel = 0;
1339 
1340  bool bBullColor = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR);
1341  bool bBullRelSize = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE);
1342  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1343  {
1344  if(nActNumLvl & nMask)
1345  {
1346  aNumFmtArr[i] = &pActNum->GetLevel(i);
1347  bShowBullet &= aNumFmtArr[i]->GetNumberingType() == SVX_NUM_CHAR_SPECIAL;
1348  bShowBitmap &= (aNumFmtArr[i]->GetNumberingType()&(~LINK_TOKEN)) == SVX_NUM_BITMAP;
1349  if(SAL_MAX_UINT16 == nLvl)
1350  {
1351  nLvl = i;
1352  sFirstCharFmt = aNumFmtArr[i]->GetCharFormatName();
1353  eFirstOrient = aNumFmtArr[i]->GetVertOrient();
1354  if(bShowBitmap)
1355  aFirstSize = aNumFmtArr[i]->GetGraphicSize();
1356  }
1357  if( i > nLvl)
1358  {
1359  bSameType &= aNumFmtArr[i]->GetNumberingType() == aNumFmtArr[nLvl]->GetNumberingType();
1360  bSameStart = aNumFmtArr[i]->GetStart() == aNumFmtArr[nLvl]->GetStart();
1361 
1362  bSamePrefix = aNumFmtArr[i]->GetPrefix() == aNumFmtArr[nLvl]->GetPrefix();
1363  bSameSuffix = aNumFmtArr[i]->GetSuffix() == aNumFmtArr[nLvl]->GetSuffix();
1364  bAllLevel &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[nLvl]->GetIncludeUpperLevels();
1365  bSameCharFmt &= sFirstCharFmt == aNumFmtArr[i]->GetCharFormatName();
1366  bSameVOrient &= eFirstOrient == aNumFmtArr[i]->GetVertOrient();
1367  if(bShowBitmap && bSameSize)
1368  bSameSize &= aNumFmtArr[i]->GetGraphicSize() == aFirstSize;
1369  bSameBulColor &= aNumFmtArr[i]->GetBulletColor() == aNumFmtArr[nLvl]->GetBulletColor();
1370  bSameBulRelSize &= aNumFmtArr[i]->GetBulletRelSize() == aNumFmtArr[nLvl]->GetBulletRelSize();
1371  }
1372  nHighestLevel = i;
1373  }
1374  else
1375  aNumFmtArr[i] = nullptr;
1376 
1377  nMask <<= 1 ;
1378  }
1379  SwitchNumberType(bShowBullet ? 1 : bShowBitmap ? 2 : 0);
1380 
1381  sal_uInt16 nNumberingType;
1382  if (nLvl != SAL_MAX_UINT16)
1383  nNumberingType = aNumFmtArr[nLvl]->GetNumberingType();
1384  else
1385  {
1386  nNumberingType = SVX_NUM_NUMBER_NONE;
1387  bAllLevel = false;
1388  bSameBulRelSize = false;
1389  bSameBulColor = false;
1390  bSameStart = false;
1391  bSamePrefix = false;
1392  bSameSuffix = false;
1393  }
1394 
1395  CheckForStartValue_Impl(nNumberingType);
1396 
1397  if(bShowBitmap)
1398  {
1399  if(!bSameVOrient || eFirstOrient == text::VertOrientation::NONE)
1400  m_xOrientLB->set_active(-1);
1401  else
1402  m_xOrientLB->set_active(
1403  sal::static_int_cast< sal_Int32 >(eFirstOrient - 1));
1404  // no text::VertOrientation::NONE
1405 
1406  if(bSameSize)
1407  {
1408  SetMetricValue(*m_xHeightMF, aFirstSize.Height(), eCoreUnit);
1409  SetMetricValue(*m_xWidthMF, aFirstSize.Width(), eCoreUnit);
1410  }
1411  else
1412  {
1413  m_xHeightMF->set_text("");
1414  m_xWidthMF->set_text("");
1415  }
1416  }
1417 
1418  if(bSameType)
1419  {
1420  sal_uInt16 nLBData = nNumberingType;
1421  m_xFmtLB->set_active_id(OUString::number(nLBData));
1422  }
1423  else
1424  m_xFmtLB->set_active(-1);
1425 
1426  m_xAllLevelNF->set_sensitive(nHighestLevel > 0 && !m_xSameLevelCB->get_active());
1427  m_xAllLevelNF->set_max(nHighestLevel + 1);
1428  if(bAllLevel)
1429  {
1430  m_xAllLevelNF->set_value(aNumFmtArr[nLvl]->GetIncludeUpperLevels());
1431  }
1432  else
1433  {
1434  m_xAllLevelNF->set_text("");
1435  }
1436 
1437  if(bBullRelSize)
1438  {
1439  if(bSameBulRelSize)
1440  m_xBulRelSizeMF->set_value(aNumFmtArr[nLvl]->GetBulletRelSize(), FieldUnit::PERCENT);
1441  else
1442  m_xBulRelSizeMF->set_text("");
1443  }
1444  if(bBullColor)
1445  {
1446  if(bSameBulColor)
1447  m_xBulColLB->SelectEntry(aNumFmtArr[nLvl]->GetBulletColor());
1448  else
1449  m_xBulColLB->SetNoSelection();
1450  }
1451  switch(nBullet)
1452  {
1453  case SHOW_NUMBERING:
1454  if(bSameStart)
1455  {
1456  m_xStartED->set_value(aNumFmtArr[nLvl]->GetStart());
1457  }
1458  else
1459  m_xStartED->set_text("");
1460  break;
1461  case SHOW_BULLET:
1462  break;
1463  case SHOW_BITMAP:
1464  break;
1465  }
1466 
1467  if(bSamePrefix)
1468  m_xPrefixED->set_text(aNumFmtArr[nLvl]->GetPrefix());
1469  else
1470  m_xPrefixED->set_text("");
1471  if(bSameSuffix)
1472  m_xSuffixED->set_text(aNumFmtArr[nLvl]->GetSuffix());
1473  else
1474  m_xSuffixED->set_text("");
1475 
1476  if(bSameCharFmt)
1477  {
1478  if (!sFirstCharFmt.isEmpty())
1479  m_xCharFmtLB->set_active_text(sFirstCharFmt);
1480  else
1481  m_xCharFmtLB->set_active(0);
1482  }
1483  else
1484  m_xCharFmtLB->set_active(-1);
1485 
1488 }
1489 
1490 // 0 - Number; 1 - Bullet; 2 - Bitmap
1492 {
1493  if(nBullet == nType)
1494  return;
1495  nBullet = nType;
1496  bool bBullet = (nType == SHOW_BULLET);
1497  bool bBitmap = (nType == SHOW_BITMAP);
1498  bool bEnableBitmap = (nType == SHOW_BITMAP);
1499  bool bNumeric = !(bBitmap||bBullet);
1500  m_xSeparatorFT->set_visible(bNumeric);
1501  m_xPrefixFT->set_visible(bNumeric);
1502  m_xPrefixED->set_visible(bNumeric);
1503  m_xSuffixFT->set_visible(bNumeric);
1504  m_xSuffixED->set_visible(bNumeric);
1505 
1506  bool bCharFmt = pActNum->IsFeatureSupported(SvxNumRuleFlags::CHAR_STYLE);
1507  m_xCharFmtFT->set_visible(!bBitmap && bCharFmt);
1508  m_xCharFmtLB->set_visible(!bBitmap && bCharFmt);
1509 
1510  // this is rather misusage, as there is no own flag
1511  // for complete numeration
1512  bool bAllLevelFeature = pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS);
1513  bool bAllLevel = bNumeric && bAllLevelFeature && !bHTMLMode;
1514  m_xAllLevelFT->set_visible(bAllLevel);
1515  m_xAllLevelNF->set_visible(bAllLevel);
1516 
1517  m_xStartFT->set_visible(!(bBullet||bBitmap));
1518  m_xStartED->set_visible(!(bBullet||bBitmap));
1519 
1520  m_xBulletFT->set_visible(bBullet);
1521  m_xBulletPB->set_visible(bBullet);
1522  bool bBullColor = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR);
1523  m_xBulColorFT->set_visible(!bBitmap && bBullColor);
1524  m_xBulColLB->set_visible(!bBitmap && bBullColor);
1525  bool bBullResSize = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE);
1526  m_xBulRelSizeFT->set_visible(!bBitmap && bBullResSize);
1527  m_xBulRelSizeMF->set_visible(!bBitmap && bBullResSize);
1528 
1529  m_xBitmapFT->set_visible(bBitmap);
1530  m_xBitmapMB->set_visible(bBitmap);
1531 
1532  m_xWidthFT->set_visible(bBitmap);
1533  m_xWidthMF->set_visible(bBitmap);
1534  m_xHeightFT->set_visible(bBitmap);
1535  m_xHeightMF->set_visible(bBitmap);
1536  m_xRatioCB->set_visible(bBitmap);
1537 
1538  m_xOrientFT->set_visible(bBitmap && bAllLevelFeature);
1539  m_xOrientLB->set_visible(bBitmap && bAllLevelFeature);
1540 
1541  m_xWidthFT->set_sensitive(bEnableBitmap);
1542  m_xWidthMF->set_sensitive(bEnableBitmap);
1543  m_xHeightFT->set_sensitive(bEnableBitmap);
1544  m_xHeightMF->set_sensitive(bEnableBitmap);
1545  m_xRatioCB->set_sensitive(bEnableBitmap);
1546  m_xOrientFT->set_sensitive(bEnableBitmap);
1547  m_xOrientLB->set_sensitive(bEnableBitmap);
1548 }
1549 
1550 IMPL_LINK(SvxNumOptionsTabPage, LevelHdl_Impl, weld::TreeView&, rBox, void)
1551 {
1552  sal_uInt16 nSaveNumLvl = nActNumLvl;
1553  nActNumLvl = 0;
1554  auto aSelectedRows = rBox.get_selected_rows();
1555  if (std::find(aSelectedRows.begin(), aSelectedRows.end(), pActNum->GetLevelCount()) != aSelectedRows.end() &&
1556  (aSelectedRows.size() == 1 || nSaveNumLvl != 0xffff))
1557  {
1558  nActNumLvl = 0xFFFF;
1559  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1560  rBox.unselect(i);
1561  }
1562  else if (!aSelectedRows.empty())
1563  {
1564  sal_uInt16 nMask = 1;
1565  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1566  {
1567  if (std::find(aSelectedRows.begin(), aSelectedRows.end(), i) != aSelectedRows.end())
1568  nActNumLvl |= nMask;
1569  nMask <<= 1;
1570  }
1571  rBox.unselect(pActNum->GetLevelCount());
1572  }
1573  else
1574  {
1575  nActNumLvl = nSaveNumLvl;
1576  sal_uInt16 nMask = 1;
1577  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
1578  {
1579  if(nActNumLvl & nMask)
1580  {
1581  rBox.select(i);
1582  break;
1583  }
1584  nMask <<=1;
1585  }
1586  }
1587  InitControls();
1588 }
1589 
1590 IMPL_LINK_NOARG(SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl, Timer *, void)
1591 {
1592  m_aPreviewWIN.Invalidate();
1593 }
1594 
1595 IMPL_LINK(SvxNumOptionsTabPage, AllLevelHdl_Impl, weld::SpinButton&, rBox, void)
1596 {
1597  sal_uInt16 nMask = 1;
1598  for(sal_uInt16 e = 0; e < pActNum->GetLevelCount(); e++)
1599  {
1600  if(nActNumLvl & nMask)
1601  {
1602  SvxNumberFormat aNumFmt(pActNum->GetLevel(e));
1603  aNumFmt.SetIncludeUpperLevels(static_cast<sal_uInt8>(std::min(rBox.get_value(), int(e + 1))) );
1604  pActNum->SetLevel(e, aNumFmt);
1605  }
1606  nMask <<= 1;
1607  }
1608  SetModified();
1609 }
1610 
1611 IMPL_LINK(SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, weld::ComboBox&, rBox, void)
1612 {
1613  OUString sSelectStyle;
1614  bool bShowOrient = false;
1615  bool bBmp = false;
1616  sal_uInt16 nMask = 1;
1617  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1618  {
1619  if(nActNumLvl & nMask)
1620  {
1621  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1622  // PAGEDESC does not exist
1623  SvxNumType nNumType = static_cast<SvxNumType>(rBox.get_active_id().toUInt32());
1624  aNumFmt.SetNumberingType(nNumType);
1625  sal_uInt16 nNumberingType = aNumFmt.GetNumberingType();
1626  if(SVX_NUM_BITMAP == (nNumberingType&(~LINK_TOKEN)))
1627  {
1628  bBmp |= nullptr != aNumFmt.GetBrush();
1629  aNumFmt.SetIncludeUpperLevels( 0 );
1630  aNumFmt.SetSuffix( "" );
1631  aNumFmt.SetPrefix( "" );
1632  if(!bBmp)
1633  aNumFmt.SetGraphic("");
1634  pActNum->SetLevel(i, aNumFmt);
1635  SwitchNumberType(SHOW_BITMAP);
1636  bShowOrient = true;
1637  }
1638  else if( SVX_NUM_CHAR_SPECIAL == nNumberingType )
1639  {
1640  aNumFmt.SetIncludeUpperLevels( 0 );
1641  aNumFmt.SetSuffix( "" );
1642  aNumFmt.SetPrefix( "" );
1643  if( !aNumFmt.GetBulletFont() )
1644  aNumFmt.SetBulletFont(&aActBulletFont);
1645  if( !aNumFmt.GetBulletChar() )
1646  aNumFmt.SetBulletChar( SVX_DEF_BULLET );
1647  pActNum->SetLevel(i, aNumFmt);
1648  SwitchNumberType(SHOW_BULLET);
1649  // allocation of the drawing pattern is automatic
1650  if(bAutomaticCharStyles)
1651  {
1652  sSelectStyle = m_sBulletCharFormatName;
1653  }
1654  }
1655  else
1656  {
1657  aNumFmt.SetPrefix( m_xPrefixED->get_text() );
1658  aNumFmt.SetSuffix( m_xSuffixED->get_text() );
1659  SwitchNumberType(SHOW_NUMBERING);
1660  pActNum->SetLevel(i, aNumFmt);
1661  CheckForStartValue_Impl(nNumberingType);
1662 
1663  // allocation of the drawing pattern is automatic
1664  if(bAutomaticCharStyles)
1665  {
1666  sSelectStyle = m_sNumCharFmtName;
1667  }
1668  }
1669  }
1670  nMask <<= 1;
1671  }
1672  bool bAllLevelFeature = pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS);
1673  if(bShowOrient && bAllLevelFeature)
1674  {
1675  m_xOrientFT->show();
1676  m_xOrientLB->show();
1677  }
1678  else
1679  {
1680  m_xOrientFT->hide();
1681  m_xOrientLB->hide();
1682  }
1683  SetModified();
1684  if(!sSelectStyle.isEmpty())
1685  {
1686  m_xCharFmtLB->set_active_text(sSelectStyle);
1687  CharFmtHdl_Impl(*m_xCharFmtLB);
1688  bAutomaticCharStyles = true;
1689  }
1690 }
1691 
1692 void SvxNumOptionsTabPage::CheckForStartValue_Impl(sal_uInt16 nNumberingType)
1693 {
1694  bool bIsNull = m_xStartED->get_value() == 0;
1695  bool bNoZeroAllowed = nNumberingType < SVX_NUM_ARABIC ||
1696  SVX_NUM_CHARS_UPPER_LETTER_N == nNumberingType ||
1697  SVX_NUM_CHARS_LOWER_LETTER_N == nNumberingType;
1698  m_xStartED->set_min(bNoZeroAllowed ? 1 : 0);
1699  if (bIsNull && bNoZeroAllowed)
1701 }
1702 
1703 IMPL_LINK(SvxNumOptionsTabPage, OrientHdl_Impl, weld::ComboBox&, rBox, void)
1704 {
1705  sal_Int32 nPos = rBox.get_active();
1706  nPos ++; // no VERT_NONE
1707 
1708  sal_uInt16 nMask = 1;
1709  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1710  {
1711  if(nActNumLvl & nMask)
1712  {
1713  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1714  if(SVX_NUM_BITMAP == (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
1715  {
1716  const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
1717  const Size& rSize = aNumFmt.GetGraphicSize();
1718  sal_Int16 eOrient = static_cast<sal_Int16>(nPos);
1719  aNumFmt.SetGraphicBrush( pBrushItem, &rSize, &eOrient );
1720  pActNum->SetLevel(i, aNumFmt);
1721  }
1722  }
1723  nMask <<= 1;
1724  }
1725  SetModified(false);
1726 }
1727 
1728 IMPL_LINK(SvxNumOptionsTabPage, SameLevelHdl_Impl, weld::ToggleButton&, rBox, void)
1729 {
1730  bool bSet = rBox.get_active();
1731  pActNum->SetContinuousNumbering(bSet);
1732  bool bRepaint = false;
1733  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1734  {
1735  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1736  if(aNumFmt.GetNumberingType() != SVX_NUM_NUMBER_NONE)
1737  {
1738  bRepaint = true;
1739  break;
1740  }
1741  }
1742  SetModified(bRepaint);
1743  InitControls();
1744 }
1745 
1746 IMPL_LINK(SvxNumOptionsTabPage, BulColorHdl_Impl, ColorListBox&, rColorBox, void)
1747 {
1748  Color nSetColor = rColorBox.GetSelectEntryColor();
1749 
1750  sal_uInt16 nMask = 1;
1751  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1752  {
1753  if(nActNumLvl & nMask)
1754  {
1755  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1756  aNumFmt.SetBulletColor(nSetColor);
1757  pActNum->SetLevel(i, aNumFmt);
1758  }
1759  nMask <<= 1;
1760  }
1761  SetModified();
1762 }
1763 
1764 IMPL_LINK(SvxNumOptionsTabPage, BulRelSizeHdl_Impl, weld::MetricSpinButton&, rField, void)
1765 {
1766  sal_uInt16 nRelSize = rField.get_value(FieldUnit::PERCENT);
1767 
1768  sal_uInt16 nMask = 1;
1769  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1770  {
1771  if(nActNumLvl & nMask)
1772  {
1773  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1774  aNumFmt.SetBulletRelSize(nRelSize);
1775  pActNum->SetLevel(i, aNumFmt);
1776  }
1777  nMask <<= 1;
1778  }
1779  SetModified();
1780 }
1781 
1782 IMPL_LINK(SvxNumOptionsTabPage, GraphicHdl_Impl, const OString&, rIdent, void)
1783 {
1784  OUString aGrfName;
1785  Size aSize;
1786  bool bSucc(false);
1787  SvxOpenGraphicDialog aGrfDlg(CuiResId(RID_SVXSTR_EDIT_GRAPHIC), GetFrameWeld());
1788 
1789  OString sNumber;
1790  if (rIdent.startsWith("gallery", &sNumber))
1791  {
1792  auto idx = sNumber.toUInt32();
1793  if (idx < aGrfNames.size())
1794  {
1795  aGrfName = aGrfNames[idx];
1796  Graphic aGraphic;
1798  {
1799  aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
1800  bSucc = true;
1801  }
1802  }
1803  }
1804  else if (rIdent == "fromfile")
1805  {
1806  aGrfDlg.EnableLink( false );
1807  aGrfDlg.AsLink( false );
1808  if ( !aGrfDlg.Execute() )
1809  {
1810  // memorize selected filter
1811  aGrfName = aGrfDlg.GetPath();
1812 
1813  Graphic aGraphic;
1814  if( !aGrfDlg.GetGraphic(aGraphic) )
1815  {
1816  aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
1817  bSucc = true;
1818  }
1819  }
1820  }
1821  if(bSucc)
1822  {
1823  aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit));
1824 
1825  sal_uInt16 nMask = 1;
1826  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1827  {
1828  if(nActNumLvl & nMask)
1829  {
1830  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1831  aNumFmt.SetCharFormatName(m_sNumCharFmtName);
1832  aNumFmt.SetGraphic(aGrfName);
1833 
1834  // set size for a later comparison
1835  const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
1836  // initiate asynchronous loading
1837  sal_Int16 eOrient = aNumFmt.GetVertOrient();
1838  aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient );
1839  aInitSize[i] = aNumFmt.GetGraphicSize();
1840 
1841  pActNum->SetLevel(i, aNumFmt);
1842  }
1843  nMask <<= 1;
1844  }
1845  m_xRatioCB->set_sensitive(true);
1846  m_xWidthFT->set_sensitive(true);
1847  m_xHeightFT->set_sensitive(true);
1848  m_xWidthMF->set_sensitive(true);
1849  m_xHeightMF->set_sensitive(true);
1850  SetMetricValue(*m_xWidthMF, aSize.Width(), eCoreUnit);
1851  SetMetricValue(*m_xHeightMF, aSize.Height(), eCoreUnit);
1852  m_xOrientFT->set_sensitive(true);
1853  m_xOrientLB->set_sensitive(true);
1854  SetModified();
1855  //needed due to asynchronous loading of graphics in the SvxBrushItem
1856  aInvalidateTimer.Start();
1857  }
1858 }
1859 
1861 {
1862  if (!m_xGalleryMenu)
1863  {
1864  m_xGalleryMenu = m_xBuilder->weld_menu("gallerysubmenu");
1865  weld::WaitObject aWait(GetFrameWeld());
1866 
1868  {
1870 
1871  Graphic aGraphic;
1872  OUString sGrfName;
1874  size_t i = 0;
1875  for (const auto & grfName : aGrfNames)
1876  {
1877  sGrfName = grfName;
1878  OUString sItemId = "gallery" + OUString::number(i);
1879  INetURLObject aObj(sGrfName);
1880  if(aObj.GetProtocol() == INetProtocol::File)
1881  sGrfName = aObj.PathToFileName();
1883  {
1884  BitmapEx aBitmap(aGraphic.GetBitmapEx());
1885  Size aSize(aBitmap.GetSizePixel());
1886  if(aSize.Width() > MAX_BMP_WIDTH ||
1887  aSize.Height() > MAX_BMP_HEIGHT)
1888  {
1889  bool bWidth = aSize.Width() > aSize.Height();
1890  double nScale = bWidth ?
1891  double(MAX_BMP_WIDTH) / static_cast<double>(aSize.Width()):
1892  double(MAX_BMP_HEIGHT) / static_cast<double>(aSize.Height());
1893  aBitmap.Scale(nScale, nScale);
1894  }
1895  pVD->SetOutputSizePixel(aBitmap.GetSizePixel(), false);
1896  pVD->DrawBitmapEx(Point(), aBitmap);
1897  m_xGalleryMenu->append(sItemId, sGrfName, *pVD);
1898  }
1899  else
1900  {
1901  m_xGalleryMenu->append(sItemId, sGrfName);
1902  }
1903  ++i;
1904  }
1906  }
1907  }
1908 }
1909 
1911 {
1912  SvxCharacterMap aMap(GetFrameWeld(), nullptr, nullptr);
1913 
1914  sal_uInt16 nMask = 1;
1915  const vcl::Font* pFmtFont = nullptr;
1916  bool bSameBullet = true;
1917  sal_Unicode cBullet = 0;
1918  bool bFirst = true;
1919  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1920  {
1921  if(nActNumLvl & nMask)
1922  {
1923  const SvxNumberFormat& rCurFmt = pActNum->GetLevel(i);
1924  if(bFirst)
1925  {
1926  cBullet = rCurFmt.GetBulletChar();
1927  }
1928  else if(rCurFmt.GetBulletChar() != cBullet )
1929  {
1930  bSameBullet = false;
1931  break;
1932  }
1933  if(!pFmtFont)
1934  pFmtFont = rCurFmt.GetBulletFont();
1935  bFirst = false;
1936  }
1937  nMask <<= 1;
1938 
1939  }
1940 
1941  if (pFmtFont)
1942  aMap.SetCharFont(*pFmtFont);
1943  else
1944  aMap.SetCharFont(aActBulletFont);
1945  if (bSameBullet)
1946  aMap.SetChar(cBullet);
1947  if (aMap.run() == RET_OK)
1948  {
1949  // change Font Numrules
1950  aActBulletFont = aMap.GetCharFont();
1951 
1952  sal_uInt16 _nMask = 1;
1953  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1954  {
1955  if(nActNumLvl & _nMask)
1956  {
1957  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1958  aNumFmt.SetBulletFont(&aActBulletFont);
1959  aNumFmt.SetBulletChar( static_cast<sal_Unicode>(aMap.GetChar()) );
1960  pActNum->SetLevel(i, aNumFmt);
1961  }
1962  _nMask <<= 1;
1963  }
1964 
1965  SetModified();
1966  }
1967 }
1968 
1970 {
1971  bool bWidth = &rField == m_xWidthMF.get();
1972  bLastWidthModified = bWidth;
1973  bool bRatio = m_xRatioCB->get_active();
1974  long nWidthVal = static_cast<long>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::MM_100TH)));
1975  long nHeightVal = static_cast<long>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FieldUnit::MM_100TH)));
1976  nWidthVal = OutputDevice::LogicToLogic( nWidthVal ,
1977  MapUnit::Map100thMM, eCoreUnit );
1978  nHeightVal = OutputDevice::LogicToLogic( nHeightVal,
1979  MapUnit::Map100thMM, eCoreUnit);
1980  double fSizeRatio;
1981 
1982  bool bRepaint = false;
1983  sal_uInt16 nMask = 1;
1984  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1985  {
1986  if(nActNumLvl & nMask)
1987  {
1988  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1989  if(SVX_NUM_BITMAP == (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
1990  {
1991  Size aSize(aNumFmt.GetGraphicSize() );
1992  Size aSaveSize(aSize);
1993 
1994  if (aInitSize[i].Height())
1995  fSizeRatio = static_cast<double>(aInitSize[i].Width()) / static_cast<double>(aInitSize[i].Height());
1996  else
1997  fSizeRatio = double(1);
1998 
1999  if(bWidth)
2000  {
2001  long nDelta = nWidthVal - aInitSize[i].Width();
2002  aSize.setWidth( nWidthVal );
2003  if (bRatio)
2004  {
2005  aSize.setHeight( aInitSize[i].Height() + static_cast<long>(static_cast<double>(nDelta) / fSizeRatio) );
2006  m_xHeightMF->set_value(m_xHeightMF->normalize(
2007  OutputDevice::LogicToLogic( aSize.Height(), eCoreUnit, MapUnit::Map100thMM )),
2008  FieldUnit::MM_100TH);
2009  }
2010  }
2011  else
2012  {
2013  long nDelta = nHeightVal - aInitSize[i].Height();
2014  aSize.setHeight( nHeightVal );
2015  if (bRatio)
2016  {
2017  aSize.setWidth( aInitSize[i].Width() + static_cast<long>(static_cast<double>(nDelta) * fSizeRatio) );
2018  m_xWidthMF->set_value(m_xWidthMF->normalize(
2019  OutputDevice::LogicToLogic( aSize.Width(), eCoreUnit, MapUnit::Map100thMM )),
2020  FieldUnit::MM_100TH);
2021  }
2022  }
2023  const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
2024  sal_Int16 eOrient = aNumFmt.GetVertOrient();
2025  if(aSize != aSaveSize)
2026  bRepaint = true;
2027  aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient );
2028  pActNum->SetLevel(i, aNumFmt);
2029  }
2030  }
2031  nMask <<= 1;
2032  }
2033  SetModified(bRepaint);
2034 }
2035 
2037 {
2038  if (rBox.get_active())
2039  {
2040  if (bLastWidthModified)
2041  SizeHdl_Impl(*m_xWidthMF);
2042  else
2043  SizeHdl_Impl(*m_xHeightMF);
2044  }
2045 }
2046 
2048 {
2049  bAutomaticCharStyles = false;
2050  sal_Int32 nEntryPos = m_xCharFmtLB->get_active();
2051  OUString sEntry = m_xCharFmtLB->get_active_text();
2052  sal_uInt16 nMask = 1;
2053  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2054  {
2055  if(nActNumLvl & nMask)
2056  {
2057  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2058  if( 0 == nEntryPos )
2059  aNumFmt.SetCharFormatName("");
2060  else
2061  {
2062  if(SVX_NUM_BITMAP != (aNumFmt.GetNumberingType()&(~LINK_TOKEN)))
2063  aNumFmt.SetCharFormatName(sEntry);
2064  }
2065  pActNum->SetLevel(i, aNumFmt);
2066  }
2067  nMask <<= 1;
2068  }
2069  SetModified(false);
2070 };
2071 
2073 {
2074  EditModifyHdl_Impl(nullptr);
2075 }
2076 
2077 IMPL_LINK(SvxNumOptionsTabPage, EditModifyHdl_Impl, weld::Entry&, rEdit, void)
2078 {
2079  EditModifyHdl_Impl(&rEdit);
2080 }
2081 
2083 {
2084  bool bPrefix = pEdit == m_xPrefixED.get();
2085  bool bSuffix = pEdit == m_xSuffixED.get();
2086  bool bStart = pEdit == m_xStartED.get();
2087  sal_uInt16 nMask = 1;
2088  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2089  {
2090  if(nActNumLvl & nMask)
2091  {
2092  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2093  if(bPrefix)
2094  aNumFmt.SetPrefix(m_xPrefixED->get_text());
2095  else if(bSuffix)
2096  aNumFmt.SetSuffix(m_xSuffixED->get_text());
2097  else if(bStart)
2098  aNumFmt.SetStart(m_xStartED->get_value());
2099  pActNum->SetLevel(i, aNumFmt);
2100  }
2101  nMask <<= 1;
2102  }
2103  SetModified();
2104 }
2105 
2106 static long lcl_DrawGraphic(VirtualDevice* pVDev, const SvxNumberFormat &rFmt, long nXStart,
2107  long nYMiddle, long nDivision)
2108 {
2109  const SvxBrushItem* pBrushItem = rFmt.GetBrush();
2110  long nRet = 0;
2111  if(pBrushItem)
2112  {
2113  const Graphic* pGrf = pBrushItem->GetGraphic();
2114  if(pGrf)
2115  {
2116  Size aGSize( rFmt.GetGraphicSize() );
2117  aGSize.setWidth( aGSize.Width() / nDivision );
2118  nRet = aGSize.Width();
2119  aGSize.setHeight( aGSize.Height() / nDivision );
2120  pGrf->Draw( pVDev, Point(nXStart,nYMiddle - ( aGSize.Height() / 2) ),
2121  pVDev->PixelToLogic( aGSize ) );
2122  }
2123  }
2124  return nRet;
2125 
2126 }
2127 
2128 static long lcl_DrawBullet(VirtualDevice* pVDev,
2129  const SvxNumberFormat& rFmt, long nXStart,
2130  long nYStart, const Size& rSize)
2131 {
2132  vcl::Font aTmpFont(pVDev->GetFont());
2133 
2134  // via Uno it's possible that no font has been set!
2135  vcl::Font aFont(rFmt.GetBulletFont() ? *rFmt.GetBulletFont() : aTmpFont);
2136  Size aTmpSize(rSize);
2137  aTmpSize.setWidth( aTmpSize.Width() * ( rFmt.GetBulletRelSize()) );
2138  aTmpSize.setWidth( aTmpSize.Width() / 100 ) ;
2139  aTmpSize.setHeight( aTmpSize.Height() * ( rFmt.GetBulletRelSize()) );
2140  aTmpSize.setHeight( aTmpSize.Height() / 100 ) ;
2141  // in case of a height of zero it is drawn in original height
2142  if(!aTmpSize.Height())
2143  aTmpSize.setHeight( 1 );
2144  aFont.SetFontSize(aTmpSize);
2145  aFont.SetTransparent(true);
2146  Color aBulletColor = rFmt.GetBulletColor();
2147  if(aBulletColor == COL_AUTO)
2148  aBulletColor = pVDev->GetFillColor().IsDark() ? COL_WHITE : COL_BLACK;
2149  else if(aBulletColor == pVDev->GetFillColor())
2150  aBulletColor.Invert();
2151  aFont.SetColor(aBulletColor);
2152  pVDev->SetFont( aFont );
2153  OUString aText(rFmt.GetBulletChar());
2154  long nY = nYStart;
2155  nY -= ((aTmpSize.Height() - rSize.Height())/ 2);
2156  pVDev->DrawText( Point(nXStart, nY), aText );
2157  long nRet = pVDev->GetTextWidth(aText);
2158 
2159  pVDev->SetFont(aTmpFont);
2160  return nRet;
2161 }
2162 
2164  : pActNum(nullptr)
2165  , bPosition(false)
2166  , nActLevel(SAL_MAX_UINT16)
2167 {
2168 }
2169 
2170 // paint preview of numeration
2171 void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& /*rRect*/)
2172 {
2173  Size aSize(rRenderContext.PixelToLogic(GetOutputSizePixel()));
2174 
2175  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
2176  const Color aBackColor = rStyleSettings.GetFieldColor();
2177  const Color aTextColor = rStyleSettings.GetFieldTextColor();
2178 
2179  ScopedVclPtrInstance<VirtualDevice> pVDev(rRenderContext);
2180  pVDev->EnableRTL(rRenderContext.IsRTLEnabled());
2181  pVDev->SetMapMode(rRenderContext.GetMapMode());
2182  pVDev->SetOutputSize(aSize);
2183 
2184  Color aLineColor(COL_LIGHTGRAY);
2185  if (aLineColor == aBackColor)
2186  aLineColor.Invert();
2187  pVDev->SetLineColor(aLineColor);
2188  pVDev->SetFillColor(aBackColor);
2189 
2190  if (pActNum)
2191  {
2192  long nWidthRelation = 30; // chapter dialog
2193 
2194  // height per level
2195  long nXStep = aSize.Width() / (3 * pActNum->GetLevelCount());
2196  if (pActNum->GetLevelCount() < 10)
2197  nXStep /= 2;
2198  long nYStart = 4;
2199  // the whole height mustn't be used for a single level
2200  long nYStep = (aSize.Height() - 6)/ (pActNum->GetLevelCount() > 1 ? pActNum->GetLevelCount() : 5);
2201 
2202  aStdFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, MsLangId::getSystemLanguage(), GetDefaultFontFlags::OnlyOne);
2203  aStdFont.SetColor(aTextColor);
2204  aStdFont.SetFillColor(aBackColor);
2205 
2206  long nFontHeight = nYStep * 6 / 10;
2207  if (bPosition)
2208  nFontHeight = nYStep * 15 / 10;
2209  aStdFont.SetFontSize(Size( 0, nFontHeight ));
2210 
2211  SvxNodeNum aNum;
2212  sal_uInt16 nPreNum = pActNum->GetLevel(0).GetStart();
2213 
2214  if (bPosition)
2215  {
2216  long nLineHeight = nFontHeight * 8 / 7;
2217  sal_uInt8 nStart = 0;
2218  while (!(nActLevel & (1<<nStart)))
2219  {
2220  nStart++;
2221  }
2222  if (nStart)
2223  nStart--;
2224  sal_uInt8 nEnd = std::min(sal_uInt8(nStart + 3), sal_uInt8(pActNum->GetLevelCount()));
2225  for (sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel)
2226  {
2227  const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel);
2228  aNum.GetLevelVal()[nLevel] = rFmt.GetStart();
2229 
2230  long nXStart( 0 );
2231  short nTextOffset( 0 );
2232  long nNumberXPos( 0 );
2234  {
2235  nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
2236  nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation;
2237  nNumberXPos = nXStart;
2238  long nFirstLineOffset = (-rFmt.GetFirstLineOffset()) / nWidthRelation;
2239 
2240  if (nFirstLineOffset <= nNumberXPos)
2241  nNumberXPos = nNumberXPos - nFirstLineOffset;
2242  else
2243  nNumberXPos = 0;
2244  // in draw this is valid
2245  if (nTextOffset < 0)
2246  nNumberXPos = nNumberXPos + nTextOffset;
2247  }
2249  {
2250  const long nTmpNumberXPos((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation);
2251  if (nTmpNumberXPos < 0)
2252  {
2253  nNumberXPos = 0;
2254  }
2255  else
2256  {
2257  nNumberXPos = nTmpNumberXPos;
2258  }
2259  }
2260 
2261  long nBulletWidth = 0;
2262  if (SVX_NUM_BITMAP == (rFmt.GetNumberingType() &(~LINK_TOKEN)))
2263  {
2264  long nYMiddle = nYStart + ( nFontHeight / 2 );
2265  nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawGraphic(pVDev.get(), rFmt, nNumberXPos, nYMiddle, nWidthRelation) : 0;
2266  }
2267  else if (SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType())
2268  {
2269  nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawBullet(pVDev.get(), rFmt, nNumberXPos, nYStart, aStdFont.GetFontSize()) : 0;
2270  }
2271  else
2272  {
2273  pVDev->SetFont(aStdFont);
2274  aNum.SetLevel(nLevel);
2276  aNum.GetLevelVal()[nLevel] = nPreNum;
2277  OUString aText(pActNum->MakeNumString( aNum ));
2278  vcl::Font aSaveFont = pVDev->GetFont();
2279  vcl::Font aColorFont(aSaveFont);
2280  Color aTmpBulletColor = rFmt.GetBulletColor();
2281  if (aTmpBulletColor == COL_AUTO)
2282  aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK;
2283  else if (aTmpBulletColor == aBackColor)
2284  aTmpBulletColor.Invert();
2285  aColorFont.SetColor(aTmpBulletColor);
2286  pVDev->SetFont(aColorFont);
2287  pVDev->DrawText(Point(nNumberXPos, nYStart), aText);
2288  pVDev->SetFont(aSaveFont);
2289  nBulletWidth = pVDev->GetTextWidth(aText);
2290  nPreNum++;
2291  }
2294  {
2295  pVDev->SetFont(aStdFont);
2296  OUString aText(' ');
2297  pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
2298  nBulletWidth = nBulletWidth + pVDev->GetTextWidth(aText);
2299  }
2300 
2301  long nTextXPos( 0 );
2303  {
2304  nTextXPos = nXStart;
2305  if (nTextOffset < 0)
2306  nTextXPos = nTextXPos + nTextOffset;
2307  if (nNumberXPos + nBulletWidth + nTextOffset > nTextXPos)
2308  nTextXPos = nNumberXPos + nBulletWidth + nTextOffset;
2309  }
2311  {
2312  switch (rFmt.GetLabelFollowedBy())
2313  {
2315  {
2316  nTextXPos = rFmt.GetListtabPos() / nWidthRelation;
2317  if (nTextXPos < nNumberXPos + nBulletWidth)
2318  {
2319  nTextXPos = nNumberXPos + nBulletWidth;
2320  }
2321  }
2322  break;
2326  {
2327  nTextXPos = nNumberXPos + nBulletWidth;
2328  }
2329  break;
2330  }
2331 
2332  nXStart = rFmt.GetIndentAt() / nWidthRelation;
2333  }
2334 
2335  ::tools::Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2));
2336  pVDev->SetFillColor(aBackColor);
2337  pVDev->DrawRect(aRect1);
2338 
2339  ::tools::Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2));
2340  pVDev->DrawRect(aRect2);
2341  nYStart += 2 * nLineHeight;
2342  }
2343  }
2344  else
2345  {
2346  //#i5153# painting gray or black rectangles as 'normal' numbering text
2347  long nWidth = pVDev->GetTextWidth("Preview");
2348  long nTextHeight = pVDev->GetTextHeight();
2349  long nRectHeight = nTextHeight * 2 / 3;
2350  long nTopOffset = nTextHeight - nRectHeight;
2351  Color aBlackColor(COL_BLACK);
2352  if (aBlackColor == aBackColor)
2353  aBlackColor.Invert();
2354 
2355  for (sal_uInt16 nLevel = 0; nLevel < pActNum->GetLevelCount(); ++nLevel, nYStart = nYStart + nYStep)
2356  {
2357  const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel);
2358  aNum.GetLevelVal()[ nLevel ] = rFmt.GetStart();
2359  long nXStart( 0 );
2360  pVDev->SetFillColor( aBackColor );
2361 
2363  {
2364  nXStart = rFmt.GetAbsLSpace() / nWidthRelation;
2365  }
2367  {
2368  const long nTmpXStart((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation);
2369  if (nTmpXStart < 0)
2370  {
2371  nXStart = 0;
2372  }
2373  else
2374  {
2375  nXStart = nTmpXStart;
2376  }
2377  }
2378  nXStart /= 2;
2379  nXStart += 2;
2380  long nTextOffset = 2 * nXStep;
2381  if (SVX_NUM_BITMAP == (rFmt.GetNumberingType()&(~LINK_TOKEN)))
2382  {
2383  if (rFmt.IsShowSymbol())
2384  {
2385  long nYMiddle = nYStart + ( nFontHeight / 2 );
2386  nTextOffset = lcl_DrawGraphic(pVDev.get(), rFmt, nXStart, nYMiddle, nWidthRelation);
2387  nTextOffset = nTextOffset + nXStep;
2388  }
2389  }
2390  else if (SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType())
2391  {
2392  if (rFmt.IsShowSymbol())
2393  {
2394  nTextOffset = lcl_DrawBullet(pVDev.get(), rFmt, nXStart, nYStart, aStdFont.GetFontSize());
2395  nTextOffset = nTextOffset + nXStep;
2396  }
2397  }
2398  else
2399  {
2400  vcl::Font aFont(aStdFont);
2401  Size aTmpSize(aStdFont.GetFontSize());
2402  if(pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE))
2403  {
2404  aTmpSize.setWidth( aTmpSize.Width() * ( rFmt.GetBulletRelSize()) );
2405  aTmpSize.setWidth( aTmpSize.Width() / 100 ) ;
2406  aTmpSize.setHeight( aTmpSize.Height() * ( rFmt.GetBulletRelSize()) );
2407  aTmpSize.setHeight( aTmpSize.Height() / 100 ) ;
2408  }
2409  if(!aTmpSize.Height())
2410  aTmpSize.setHeight( 1 );
2411  aFont.SetFontSize(aTmpSize);
2412  Color aTmpBulletColor = rFmt.GetBulletColor();
2413  if (aTmpBulletColor == COL_AUTO)
2414  aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK;
2415  else if (aTmpBulletColor == aBackColor)
2416  aTmpBulletColor.Invert();
2417  aFont.SetColor(aTmpBulletColor);
2418  pVDev->SetFont(aFont);
2419  aNum.SetLevel( nLevel );
2421  aNum.GetLevelVal()[nLevel] = nPreNum;
2422  OUString aText(pActNum->MakeNumString(aNum));
2423  long nY = nYStart;
2424  nY -= (pVDev->GetTextHeight() - nTextHeight - pVDev->GetFontMetric().GetDescent());
2425  pVDev->DrawText(Point(nXStart, nY), aText);
2426  nTextOffset = pVDev->GetTextWidth(aText);
2427  nTextOffset = nTextOffset + nXStep;
2428  nPreNum++;
2429  pVDev->SetFont(aStdFont);
2430  }
2431  //#i5153# the selected rectangle(s) should be black
2432  if (0 != (nActLevel & (1<<nLevel)))
2433  {
2434  pVDev->SetFillColor( aBlackColor );
2435  pVDev->SetLineColor( aBlackColor );
2436  }
2437  else
2438  {
2439  //#i5153# unselected levels are gray
2440  pVDev->SetFillColor( aLineColor );
2441  pVDev->SetLineColor( aLineColor );
2442  }
2443  ::tools::Rectangle aRect1(Point(nXStart + nTextOffset, nYStart + nTopOffset), Size(nWidth, nRectHeight));
2444  pVDev->DrawRect(aRect1);
2445  }
2446  }
2447  }
2448  rRenderContext.DrawOutDev(Point(), aSize, Point(), aSize, *pVDev);
2449 }
2450 
2451 
2452 //See uiconfig/swriter/ui/outlinepositionpage.ui for effectively a duplicate
2453 //dialog to this one, except with a different preview window impl.
2454 //TODO, determine if SwNumPositionTabPage and SvxNumPositionTabPage can be
2455 //merged
2457  : SfxTabPage(pPage, pController, "cui/ui/numberingpositionpage.ui", "NumberingPositionPage", &rSet)
2458  , m_pLevelHdlEvent(nullptr)
2459  , nActNumLvl(1)
2460  , nNumItemId(SID_ATTR_NUMBERING_RULE)
2461  , bModified(false)
2462  , bPreset(false)
2463  , bInInintControl(false)
2464  , bLabelAlignmentPosAndSpaceModeActive(false)
2465  , m_xLevelLB(m_xBuilder->weld_tree_view("levellb"))
2466  , m_xDistBorderFT(m_xBuilder->weld_label("indent"))
2467  , m_xDistBorderMF(m_xBuilder->weld_metric_spin_button("indentmf", FieldUnit::CM))
2468  , m_xRelativeCB(m_xBuilder->weld_check_button("relative"))
2469  , m_xIndentFT(m_xBuilder->weld_label("numberingwidth"))
2470  , m_xIndentMF(m_xBuilder->weld_metric_spin_button("numberingwidthmf", FieldUnit::CM))
2471  , m_xDistNumFT(m_xBuilder->weld_label("numdist"))
2472  , m_xDistNumMF(m_xBuilder->weld_metric_spin_button("numdistmf", FieldUnit::CM))
2473  , m_xAlignFT(m_xBuilder->weld_label("numalign"))
2474  , m_xAlignLB(m_xBuilder->weld_combo_box("numalignlb"))
2475  , m_xLabelFollowedByFT(m_xBuilder->weld_label("numfollowedby"))
2476  , m_xLabelFollowedByLB(m_xBuilder->weld_combo_box("numfollowedbylb"))
2477  , m_xListtabFT(m_xBuilder->weld_label("at"))
2478  , m_xListtabMF(m_xBuilder->weld_metric_spin_button("atmf", FieldUnit::CM))
2479  , m_xAlign2FT(m_xBuilder->weld_label("num2align"))
2480  , m_xAlign2LB(m_xBuilder->weld_combo_box("num2alignlb"))
2481  , m_xAlignedAtFT(m_xBuilder->weld_label("alignedat"))
2482  , m_xAlignedAtMF(m_xBuilder->weld_metric_spin_button("alignedatmf", FieldUnit::CM))
2483  , m_xIndentAtFT(m_xBuilder->weld_label("indentat"))
2484  , m_xIndentAtMF(m_xBuilder->weld_metric_spin_button("indentatmf", FieldUnit::CM))
2485  , m_xStandardPB(m_xBuilder->weld_button("standard"))
2486  , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN))
2487 {
2489 
2490  m_xAlignedAtMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE);
2491  m_xListtabMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE);
2492  m_xIndentAtMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE);
2493 
2494  m_xRelativeCB->set_active(true);
2495  m_xAlignLB->connect_changed(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl));
2496  m_xAlign2LB->connect_changed(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl));
2497  for ( sal_Int32 i = 0; i < m_xAlignLB->get_count(); ++i )
2498  {
2499  m_xAlign2LB->append_text(m_xAlignLB->get_text(i));
2500  }
2501 
2502  Link<weld::MetricSpinButton&,void> aLk3 = LINK(this, SvxNumPositionTabPage, DistanceHdl_Impl);
2503  m_xDistBorderMF->connect_value_changed(aLk3);
2504  m_xDistNumMF->connect_value_changed(aLk3);
2505  m_xIndentMF->connect_value_changed(aLk3);
2506 
2507  m_xLabelFollowedByLB->connect_changed(LINK(this, SvxNumPositionTabPage, LabelFollowedByHdl_Impl));
2508 
2509  m_xListtabMF->connect_value_changed(LINK(this, SvxNumPositionTabPage, ListtabPosHdl_Impl));
2510  m_xAlignedAtMF->connect_value_changed(LINK(this, SvxNumPositionTabPage, AlignAtHdl_Impl));
2511  m_xIndentAtMF->connect_value_changed(LINK(this, SvxNumPositionTabPage, IndentAtHdl_Impl));
2512 
2513  m_xLevelLB->set_selection_mode(SelectionMode::Multiple);
2514  m_xLevelLB->connect_changed(LINK(this, SvxNumPositionTabPage, LevelHdl_Impl));
2515  m_xRelativeCB->connect_toggled(LINK(this, SvxNumPositionTabPage, RelativeHdl_Impl));
2516  m_xStandardPB->connect_clicked(LINK(this, SvxNumPositionTabPage, StandardHdl_Impl));
2517 
2518  m_xRelativeCB->set_active(bLastRelative);
2520  eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
2521 }
2522 
2524 {
2525  if (m_pLevelHdlEvent)
2526  {
2528  m_pLevelHdlEvent = nullptr;
2529  }
2530  m_xPreviewWIN.reset();
2531 }
2532 
2533 /*-------------------------------------------------------*/
2534 
2536 {
2537  bInInintControl = true;
2538  const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive &&
2539  m_xRelativeCB->get_sensitive() && m_xRelativeCB->get_active();
2540  const bool bSingleSelection = m_xLevelLB->count_selected_rows() == 1 &&
2542 
2544  ( bSingleSelection || bRelative ) );
2546  ( bSingleSelection || bRelative ) );
2547 
2548  bool bSetDistEmpty = false;
2549  bool bSameDistBorderNum = !bLabelAlignmentPosAndSpaceModeActive;
2550  bool bSameDist = !bLabelAlignmentPosAndSpaceModeActive;
2551  bool bSameIndent = !bLabelAlignmentPosAndSpaceModeActive;
2552  bool bSameAdjust = true;
2553 
2554  bool bSameLabelFollowedBy = bLabelAlignmentPosAndSpaceModeActive;
2555  bool bSameListtab = bLabelAlignmentPosAndSpaceModeActive;
2556  bool bSameAlignAt = bLabelAlignmentPosAndSpaceModeActive;
2557  bool bSameIndentAt = bLabelAlignmentPosAndSpaceModeActive;
2558 
2559  const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
2560  sal_uInt16 nMask = 1;
2561  sal_uInt16 nLvl = SAL_MAX_UINT16;
2562  long nFirstBorderTextRelative = -1;
2563  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2564  {
2565  aNumFmtArr[i] = &pActNum->GetLevel(i);
2566  if(nActNumLvl & nMask)
2567  {
2568  if(SAL_MAX_UINT16 == nLvl)
2569  nLvl = i;
2570 
2571  if( i > nLvl)
2572  {
2573  bSameAdjust &= aNumFmtArr[i]->GetNumAdjust() == aNumFmtArr[nLvl]->GetNumAdjust();
2575  {
2576  if(bRelative)
2577  {
2578  if(nFirstBorderTextRelative == -1)
2579  nFirstBorderTextRelative =
2580  (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
2581  aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
2582  else
2583  bSameDistBorderNum &= nFirstBorderTextRelative ==
2584  (aNumFmtArr[i]->GetAbsLSpace() + aNumFmtArr[i]->GetFirstLineOffset() -
2585  aNumFmtArr[i - 1]->GetAbsLSpace() + aNumFmtArr[i - 1]->GetFirstLineOffset());
2586  }
2587  else
2588  bSameDistBorderNum &=
2589  aNumFmtArr[i]->GetAbsLSpace() - aNumFmtArr[i]->GetFirstLineOffset() ==
2590  aNumFmtArr[i - 1]->GetAbsLSpace() - aNumFmtArr[i - 1]->GetFirstLineOffset();
2591 
2592  bSameDist &= aNumFmtArr[i]->GetCharTextDistance() == aNumFmtArr[nLvl]->GetCharTextDistance();
2593  bSameIndent &= aNumFmtArr[i]->GetFirstLineOffset() == aNumFmtArr[nLvl]->GetFirstLineOffset();
2594  }
2595  else
2596  {
2597  bSameLabelFollowedBy &=
2598  aNumFmtArr[i]->GetLabelFollowedBy() == aNumFmtArr[nLvl]->GetLabelFollowedBy();
2599  bSameListtab &=
2600  aNumFmtArr[i]->GetListtabPos() == aNumFmtArr[nLvl]->GetListtabPos();
2601  bSameAlignAt &=
2602  ( ( aNumFmtArr[i]->GetIndentAt() + aNumFmtArr[i]->GetFirstLineIndent() )
2603  == ( aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent() ) );
2604  bSameIndentAt &=
2605  aNumFmtArr[i]->GetIndentAt() == aNumFmtArr[nLvl]->GetIndentAt();
2606  }
2607  }
2608  }
2609  nMask <<= 1;
2610 
2611  }
2612  if (SVX_MAX_NUM <= nLvl)
2613  {
2614  OSL_ENSURE(false, "cannot happen.");
2615  return;
2616  }
2617 
2618  if(bSameDistBorderNum)
2619  {
2620  long nDistBorderNum;
2621  if(bRelative)
2622  {
2623  nDistBorderNum = static_cast<long>(aNumFmtArr[nLvl]->GetAbsLSpace())+ aNumFmtArr[nLvl]->GetFirstLineOffset();
2624  if(nLvl)
2625  nDistBorderNum -= static_cast<long>(aNumFmtArr[nLvl - 1]->GetAbsLSpace())+ aNumFmtArr[nLvl - 1]->GetFirstLineOffset();
2626  }
2627  else
2628  {
2629  nDistBorderNum = static_cast<long>(aNumFmtArr[nLvl]->GetAbsLSpace())+ aNumFmtArr[nLvl]->GetFirstLineOffset();
2630  }
2631  SetMetricValue(*m_xDistBorderMF, nDistBorderNum, eCoreUnit);
2632  }
2633  else
2634  bSetDistEmpty = true;
2635 
2636  if(bSameDist)
2637  SetMetricValue(*m_xDistNumMF, aNumFmtArr[nLvl]->GetCharTextDistance(), eCoreUnit);
2638  else
2639  m_xDistNumMF->set_text("");
2640  if(bSameIndent)
2641  SetMetricValue(*m_xIndentMF, - aNumFmtArr[nLvl]->GetFirstLineOffset(), eCoreUnit);
2642  else
2643  m_xIndentMF->set_text("");
2644 
2645  if(bSameAdjust)
2646  {
2647  sal_Int32 nPos = 1; // centered
2648  if(aNumFmtArr[nLvl]->GetNumAdjust() == SvxAdjust::Left)
2649  nPos = 0;
2650  else if(aNumFmtArr[nLvl]->GetNumAdjust() == SvxAdjust::Right)
2651  nPos = 2;
2652  m_xAlignLB->set_active(nPos);
2653  m_xAlign2LB->set_active(nPos);
2654  }
2655  else
2656  {
2657  m_xAlignLB->set_active(-1);
2658  m_xAlign2LB->set_active(-1);
2659  }
2660 
2661  if ( bSameLabelFollowedBy )
2662  {
2663  sal_Int32 nPos = 0; // LISTTAB
2664  if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::SPACE )
2665  {
2666  nPos = 1;
2667  }
2668  else if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NOTHING )
2669  {
2670  nPos = 2;
2671  }
2672  else if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::NEWLINE )
2673  {
2674  nPos = 3;
2675  }
2676  m_xLabelFollowedByLB->set_active(nPos);
2677  }
2678  else
2679  {
2680  m_xLabelFollowedByLB->set_active(-1);
2681  }
2682 
2683  if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
2684  {
2685  m_xListtabFT->set_sensitive(true);
2686  m_xListtabMF->set_sensitive(true);
2687  if ( bSameListtab )
2688  {
2689  SetMetricValue(*m_xListtabMF, aNumFmtArr[nLvl]->GetListtabPos(), eCoreUnit);
2690  }
2691  else
2692  {
2693  m_xListtabMF->set_text("");
2694  }
2695  }
2696  else
2697  {
2698  m_xListtabFT->set_sensitive(false);
2699  m_xListtabMF->set_sensitive(false);
2700  m_xListtabMF->set_text("");
2701  }
2702 
2703  if ( bSameAlignAt )
2704  {
2706  aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent(),
2707  eCoreUnit);
2708  }
2709  else
2710  {
2711  m_xAlignedAtMF->set_text("");
2712  }
2713 
2714  if ( bSameIndentAt )
2715  {
2716  SetMetricValue(*m_xIndentAtMF, aNumFmtArr[nLvl]->GetIndentAt(), eCoreUnit);
2717  }
2718  else
2719  {
2720  m_xIndentAtMF->set_text("");
2721  }
2722 
2723  if ( bSetDistEmpty )
2724  m_xDistBorderMF->set_text("");
2725 
2726  bInInintControl = false;
2727 }
2728 
2730 {
2731  const SfxPoolItem* pItem;
2732  sal_uInt16 nTmpNumLvl = 1;
2733  const SfxItemSet* pExampleSet = GetDialogExampleSet();
2734  if(pExampleSet)
2735  {
2736  if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
2737  bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue();
2738  if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
2739  nTmpNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
2740  }
2741  if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
2742  {
2743  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
2744  }
2745  bModified = (!pActNum->Get( 0 ) || bPreset);
2746  if(*pSaveNum != *pActNum ||
2747  nActNumLvl != nTmpNumLvl )
2748  {
2749  *pActNum = *pSaveNum;
2750  nActNumLvl = nTmpNumLvl;
2751  sal_uInt16 nMask = 1;
2752  m_xLevelLB->unselect_all();
2753  if (nActNumLvl == SAL_MAX_UINT16)
2754  m_xLevelLB->select(pActNum->GetLevelCount());
2755  if (nActNumLvl != SAL_MAX_UINT16)
2756  for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2757  {
2758  if (nActNumLvl & nMask)
2759  m_xLevelLB->select(i);
2760  nMask <<= 1 ;
2761  }
2762  m_xRelativeCB->set_sensitive(nActNumLvl != 1);
2763 
2766 
2767  InitControls();
2768  }
2771 }
2772 
2774 {
2775  if(_pSet)
2776  {
2777  if (m_xDistBorderMF->get_sensitive())
2778  DistanceHdl_Impl(*m_xDistBorderMF);
2779  DistanceHdl_Impl(*m_xIndentMF);
2780  FillItemSet(_pSet);
2781  }
2782  return DeactivateRC::LeavePage;
2783 }
2784 
2786 {
2787  rSet->Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
2788 
2789  if(bModified && pActNum)
2790  {
2791  *pSaveNum = *pActNum;
2793  rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, false));
2794  }
2795  return bModified;
2796 }
2797 
2799 {
2800  const SfxPoolItem* pItem;
2801  // in Draw the item exists as WhichId, in Writer only as SlotId
2802  SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
2803  if(eState != SfxItemState::SET)
2804  {
2805  nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
2806  eState = rSet->GetItemState(nNumItemId, false, &pItem);
2807 
2808  if( eState != SfxItemState::SET )
2809  {
2810  pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) );
2811  eState = SfxItemState::SET;
2812  }
2813 
2814  }
2815  DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
2816  pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
2817 
2818  // insert levels
2819  if (!m_xLevelLB->count_selected_rows())
2820  {
2821  for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
2822  m_xLevelLB->append_text(OUString::number(i));
2823  if(pSaveNum->GetLevelCount() > 1)
2824  {
2825  OUString sEntry = "1 - " + OUString::number( pSaveNum->GetLevelCount() );
2826  m_xLevelLB->append_text(sEntry);
2827  m_xLevelLB->select_text(sEntry);
2828  }
2829  else
2830  m_xLevelLB->select(0);
2831  }
2832  else
2833  m_xLevelLB->select(m_xLevelLB->count_selected_rows() - 1);
2834  sal_uInt16 nMask = 1;
2835  m_xLevelLB->unselect_all();
2836  if (nActNumLvl == SAL_MAX_UINT16)
2837  {
2838  m_xLevelLB->select(pSaveNum->GetLevelCount());
2839  }
2840  else
2841  {
2842  for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
2843  {
2844  if(nActNumLvl & nMask)
2845  m_xLevelLB->select(i);
2846  nMask <<= 1;
2847  }
2848  }
2849 
2850  if(!pActNum)
2851  pActNum.reset( new SvxNumRule(*pSaveNum) );
2852  else if(*pSaveNum != *pActNum)
2853  *pActNum = *pSaveNum;
2855 
2858 
2859  InitControls();
2860  bModified = false;
2861 }
2862 
2864 {
2865  if ( pActNum == nullptr )
2866  {
2867  SAL_WARN( "cui.tabpages",
2868  "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of method -> <pAktNum> has to be already set!" );
2869  return;
2870  }
2871 
2874  sal_uInt16 nMask = 1;
2875  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
2876  {
2877  if(nActNumLvl & nMask)
2878  {
2879  SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
2880  ePosAndSpaceMode = aNumFmt.GetPositionAndSpaceMode();
2881  if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
2882  {
2883  break;
2884  }
2885  }
2886  nMask <<= 1;
2887  }
2888 
2890  ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT;
2891 }
2892 
2894 {
2901  pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS) );
2903  pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS));
2906 
2917 }
2918 
2919 std::unique_ptr<SfxTabPage> SvxNumPositionTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
2920  const SfxItemSet* rAttrSet)
2921 {
2922  return std::make_unique<SvxNumPositionTabPage>(pPage, pController, *rAttrSet);
2923 }
2924 
2926 {
2927  if (eMetric == FieldUnit::MM)
2928  {
2929  m_xDistBorderMF->set_digits(1);
2930  m_xDistNumMF->set_digits(1);
2931  m_xIndentMF->set_digits(1);
2932  m_xListtabMF->set_digits(1);
2933  m_xAlignedAtMF->set_digits(1);
2934  m_xIndentAtMF->set_digits(1);
2935  }
2936  m_xDistBorderMF->set_unit(eMetric);
2937  m_xDistNumMF->set_unit(eMetric);
2938  m_xIndentMF->set_unit(eMetric);
2939  m_xListtabMF->set_unit(eMetric);
2940  m_xAlignedAtMF->set_unit(eMetric);
2941  m_xIndentAtMF->set_unit(eMetric);
2942 }
2943 
2945 {
2946  sal_uInt16 nMask = 1;
2947  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
2948  {
2949  if(nActNumLvl & nMask)
2950  {
2951  SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
2952 
2953  const sal_Int32 nPos = m_xAlignLB->get_visible()
2954  ? m_xAlignLB->get_active()
2955  : m_xAlign2LB->get_active();
2956  SvxAdjust eAdjust = SvxAdjust::Center;
2957  if(nPos == 0)
2958  eAdjust = SvxAdjust::Left;
2959  else if(nPos == 2)
2960  eAdjust = SvxAdjust::Right;
2961  aNumFmt.SetNumAdjust( eAdjust );
2962  pActNum->SetLevel(i, aNumFmt);
2963  }
2964  nMask <<= 1;
2965  }
2966  SetModified();
2967 }
2968 
2970 {
2971  if (m_pLevelHdlEvent)
2972  return;
2973  // tdf#127120 multiselection may be implemented by deselect follow by select so
2974  // fire off the handler to happen on next event loop and only process the
2975  // final state
2976  m_pLevelHdlEvent = Application::PostUserEvent(LINK(this, SvxNumPositionTabPage, LevelHdl));
2977 }
2978 
2980 {
2981  m_pLevelHdlEvent = nullptr;
2982 
2983  sal_uInt16 nSaveNumLvl = nActNumLvl;
2984  nActNumLvl = 0;
2985  std::vector<int> aSelectedRows = m_xLevelLB->get_selected_rows();
2986  if (std::find(aSelectedRows.begin(), aSelectedRows.end(), pActNum->GetLevelCount()) != aSelectedRows.end() &&
2987  (aSelectedRows.size() == 1 || nSaveNumLvl != 0xffff))
2988  {
2989  nActNumLvl = 0xFFFF;
2990  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
2991  m_xLevelLB->unselect(i);
2992  }
2993  else if (!aSelectedRows.empty())
2994  {
2995  sal_uInt16 nMask = 1;
2996  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
2997  {
2998  if (std::find(aSelectedRows.begin(), aSelectedRows.end(), i) != aSelectedRows.end())
2999  nActNumLvl |= nMask;
3000  nMask <<= 1;
3001  }
3002  m_xLevelLB->unselect(pActNum->GetLevelCount());
3003  }
3004  else
3005  {
3006  nActNumLvl = nSaveNumLvl;
3007  sal_uInt16 nMask = 1;
3008  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ )
3009  {
3010  if(nActNumLvl & nMask)
3011  {
3012  m_xLevelLB->select(i);
3013  break;
3014  }
3015  nMask <<=1;
3016  }
3017  }
3018  m_xRelativeCB->set_sensitive(nActNumLvl != 1);
3019  SetModified();
3020  InitPosAndSpaceMode();
3021  ShowControlsDependingOnPosAndSpaceMode();
3022  InitControls();
3023 }
3024 
3026 {
3027  if(bInInintControl)
3028  return;
3029  long nValue = GetCoreValue(rFld, eCoreUnit);
3030  sal_uInt16 nMask = 1;
3031  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3032  {
3033  if(nActNumLvl & nMask)
3034  {
3035  SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) );
3036  if (&rFld == m_xDistBorderMF.get())
3037  {
3038 
3039  if (m_xRelativeCB->get_active())
3040  {
3041  if(0 == i)
3042  {
3043  auto const nTmp = aNumFmt.GetFirstLineOffset();
3044  aNumFmt.SetAbsLSpace( nValue - nTmp);
3045  }
3046  else
3047  {
3048  long nTmp = pActNum->GetLevel( i - 1 ).GetAbsLSpace() +
3049  pActNum->GetLevel( i - 1 ).GetFirstLineOffset() -
3050  pActNum->GetLevel( i ).GetFirstLineOffset();
3051 
3052  aNumFmt.SetAbsLSpace( nValue + nTmp);
3053  }
3054  }
3055  else
3056  {
3057  aNumFmt.SetAbsLSpace( nValue - aNumFmt.GetFirstLineOffset());
3058  }
3059  }
3060  else if (&rFld == m_xDistNumMF.get())
3061  {
3062  aNumFmt.SetCharTextDistance( static_cast<short>(nValue) );
3063  }
3064  else if (&rFld == m_xIndentMF.get())
3065  {
3066  // together with the FirstLineOffset the AbsLSpace must be changed, too
3067  long nDiff = nValue + aNumFmt.GetFirstLineOffset();
3068  auto const nAbsLSpace = aNumFmt.GetAbsLSpace();
3069  aNumFmt.SetAbsLSpace(nAbsLSpace + nDiff);
3070  aNumFmt.SetFirstLineOffset( -nValue );
3071  }
3072 
3073  pActNum->SetLevel( i, aNumFmt );
3074  }
3075  nMask <<= 1;
3076  }
3077 
3078  SetModified();
3079  if (!m_xDistBorderMF->get_sensitive())
3080  {
3081  m_xDistBorderMF->set_text("");
3082  }
3083 }
3084 
3085 IMPL_LINK(SvxNumPositionTabPage, RelativeHdl_Impl, weld::ToggleButton&, rBox, void)
3086 {
3087  bool bOn = rBox.get_active();
3088  bool bSingleSelection = m_xLevelLB->count_selected_rows() == 1 && SAL_MAX_UINT16 != nActNumLvl;
3089  bool bSetValue = false;
3090  long nValue = 0;
3091  if(bOn || bSingleSelection)
3092  {
3093  sal_uInt16 nMask = 1;
3094  bool bFirst = true;
3095  bSetValue = true;
3096  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3097  {
3098  if(nActNumLvl & nMask)
3099  {
3100  const SvxNumberFormat &rNumFmt = pActNum->GetLevel(i);
3101  if(bFirst)
3102  {
3103  nValue = rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset();
3104  if(bOn && i)
3105  nValue -= (pActNum->GetLevel(i - 1).GetAbsLSpace() + pActNum->GetLevel(i - 1).GetFirstLineOffset());
3106  }
3107  else
3108  bSetValue = nValue ==
3109  (rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset()) -
3110  (pActNum->GetLevel(i - 1).GetAbsLSpace() + pActNum->GetLevel(i - 1).GetFirstLineOffset());
3111  bFirst = false;
3112  }
3113  nMask <<= 1;
3114  }
3115 
3116  }
3117  if(bSetValue)
3118  SetMetricValue(*m_xDistBorderMF, nValue, eCoreUnit);
3119  else
3120  m_xDistBorderMF->set_text("");
3121  m_xDistBorderMF->set_sensitive(bOn || bSingleSelection);
3122  m_xDistBorderFT->set_sensitive(bOn || bSingleSelection);
3123  bLastRelative = bOn;
3124 }
3125 
3126 IMPL_LINK_NOARG(SvxNumPositionTabPage, LabelFollowedByHdl_Impl, weld::ComboBox&, void)
3127 {
3128  // determine value to be set at the chosen list levels
3130  {
3131  const auto nPos = m_xLabelFollowedByLB->get_active();
3132  if ( nPos == 1 )
3133  {
3134  eLabelFollowedBy = SvxNumberFormat::SPACE;
3135  }
3136  else if ( nPos == 2 )
3137  {
3138  eLabelFollowedBy = SvxNumberFormat::NOTHING;
3139  }
3140  else if ( nPos == 3 )
3141  {
3142  eLabelFollowedBy = SvxNumberFormat::NEWLINE;
3143  }
3144  }
3145 
3146  // set value at the chosen list levels
3147  bool bSameListtabPos = true;
3148  sal_uInt16 nFirstLvl = SAL_MAX_UINT16;
3149  sal_uInt16 nMask = 1;
3150  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3151  {
3152  if ( nActNumLvl & nMask )
3153  {
3154  SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3155  aNumFmt.SetLabelFollowedBy( eLabelFollowedBy );
3156  pActNum->SetLevel( i, aNumFmt );
3157 
3158  if ( nFirstLvl == SAL_MAX_UINT16 )
3159  {
3160  nFirstLvl = i;
3161  }
3162  else
3163  {
3164  bSameListtabPos &= aNumFmt.GetListtabPos() ==
3165  pActNum->GetLevel( nFirstLvl ).GetListtabPos();
3166  }
3167  }
3168  nMask <<= 1;
3169  }
3170 
3171  // enable/disable metric field for list tab stop position depending on
3172  // selected item following the list label.
3173  m_xListtabFT->set_sensitive( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
3174  m_xListtabMF->set_sensitive( eLabelFollowedBy == SvxNumberFormat::LISTTAB );
3175  if ( bSameListtabPos && eLabelFollowedBy == SvxNumberFormat::LISTTAB )
3176  {
3177  SetMetricValue(*m_xListtabMF, pActNum->GetLevel( nFirstLvl ).GetListtabPos(), eCoreUnit);
3178  }
3179  else
3180  {
3181  m_xListtabMF->set_text(OUString());
3182  }
3183 
3184  SetModified();
3185 }
3186 
3187 IMPL_LINK(SvxNumPositionTabPage, ListtabPosHdl_Impl, weld::MetricSpinButton&, rFld, void)
3188 {
3189  // determine value to be set at the chosen list levels
3190  const long nValue = GetCoreValue(rFld, eCoreUnit);
3191 
3192  // set value at the chosen list levels
3193  sal_uInt16 nMask = 1;
3194  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3195  {
3196  if ( nActNumLvl & nMask )
3197  {
3198  SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3199  aNumFmt.SetListtabPos( nValue );
3200  pActNum->SetLevel( i, aNumFmt );
3201  }
3202  nMask <<= 1;
3203  }
3204 
3205  SetModified();
3206 }
3207 
3209 {
3210  // determine value to be set at the chosen list levels
3211  const long nValue = GetCoreValue(rFld, eCoreUnit);
3212 
3213  // set value at the chosen list levels
3214  sal_uInt16 nMask = 1;
3215  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3216  {
3217  if ( nActNumLvl & nMask )
3218  {
3219  SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3220  const long nFirstLineIndent = nValue - aNumFmt.GetIndentAt();
3221  aNumFmt.SetFirstLineIndent( nFirstLineIndent );
3222  pActNum->SetLevel( i, aNumFmt );
3223  }
3224  nMask <<= 1;
3225  }
3226 
3227  SetModified();
3228 }
3229 
3231 {
3232  // determine value to be set at the chosen list levels
3233  const long nValue = GetCoreValue(rFld, eCoreUnit);
3234 
3235  // set value at the chosen list levels
3236  sal_uInt16 nMask = 1;
3237  for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i )
3238  {
3239  if ( nActNumLvl & nMask )
3240  {
3241  SvxNumberFormat aNumFmt( pActNum->GetLevel(i) );
3242  const long nAlignedAt = aNumFmt.GetIndentAt() +
3243  aNumFmt.GetFirstLineIndent();
3244  aNumFmt.SetIndentAt( nValue );
3245  const long nNewFirstLineIndent = nAlignedAt - nValue;
3246  aNumFmt.SetFirstLineIndent( nNewFirstLineIndent );
3247  pActNum->SetLevel( i, aNumFmt );
3248  }
3249  nMask <<= 1;
3250  }
3251 
3252  SetModified();
3253 }
3254 
3256 {
3257  sal_uInt16 nMask = 1;
3258  SvxNumRule aTmpNumRule( pActNum->GetFeatureFlags(),
3259  pActNum->GetLevelCount(),
3260  pActNum->IsContinuousNumbering(),
3261  SvxNumRuleType::NUMBERING,
3262  pActNum->GetLevel( 0 ).GetPositionAndSpaceMode() );
3263  for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
3264  {
3265  if(nActNumLvl & nMask)
3266  {
3267  SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) );
3268  const SvxNumberFormat& aTempFmt(aTmpNumRule.GetLevel( i ));
3269  aNumFmt.SetPositionAndSpaceMode( aTempFmt.GetPositionAndSpaceMode() );
3270  if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
3271  {
3272  aNumFmt.SetAbsLSpace( aTempFmt.GetAbsLSpace() );
3273  aNumFmt.SetCharTextDistance( aTempFmt.GetCharTextDistance() );
3274  aNumFmt.SetFirstLineOffset( aTempFmt.GetFirstLineOffset() );
3275  }
3276  else if ( aTempFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
3277  {
3278  aNumFmt.SetNumAdjust( aTempFmt.GetNumAdjust() );
3279  aNumFmt.SetLabelFollowedBy( aTempFmt.GetLabelFollowedBy() );
3280  aNumFmt.SetListtabPos( aTempFmt.GetListtabPos() );
3281  aNumFmt.SetFirstLineIndent( aTempFmt.GetFirstLineIndent() );
3282  aNumFmt.SetIndentAt( aTempFmt.GetIndentAt() );
3283  }
3284 
3285  pActNum->SetLevel( i, aNumFmt );
3286  }
3287  nMask <<= 1;
3288  }
3289 
3290  InitControls();
3291  SetModified();
3292 }
3293 
3295 {
3296  bModified = true;
3299 }
3300 
3302 {
3303  bModified = true;
3304  if (bRepaint)
3305  {
3308  }
3309 }
3310 
3312 {
3313  const SfxStringListItem* pListItem = aSet.GetItem<SfxStringListItem>(SID_CHAR_FMT_LIST_BOX, false);
3314  const SfxStringItem* pNumCharFmt = aSet.GetItem<SfxStringItem>(SID_NUM_CHAR_FMT, false);
3315  const SfxStringItem* pBulletCharFmt = aSet.GetItem<SfxStringItem>(SID_BULLET_CHAR_FMT, false);
3316  const SfxUInt16Item* pMetricItem = aSet.GetItem<SfxUInt16Item>(SID_METRIC_ITEM, false);
3317 
3318  if (pNumCharFmt &&pBulletCharFmt)
3319  SetCharFmts( pNumCharFmt->GetValue(),pBulletCharFmt->GetValue());
3320 
3321  if (pListItem)
3322  {
3323  const std::vector<OUString> &aList = pListItem->GetList();
3324  sal_uInt32 nCount = aList.size();
3325  for(sal_uInt32 i = 0; i < nCount; i++)
3326  m_xCharFmtLB->append_text(aList[i]);
3327  }
3328  if (pMetricItem)
3329  SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
3330 }
3331 
3333 {
3334  const SfxUInt16Item* pMetricItem = aSet.GetItem<SfxUInt16Item>(SID_METRIC_ITEM, false);
3335 
3336  if (pMetricItem)
3337  SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
3338 }
3339 
3340 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFamily(FontFamily)
std::unique_ptr< weld::Label > m_xErrorText
Definition: numpages.hxx:172
std::unique_ptr< weld::Label > m_xDistNumFT
Definition: numpages.hxx:329
SvxNumType GetNumberingType() const
long Width() const
#define SHOW_NUMBERING
Definition: numpages.cxx:83
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
void SetFillColor(const Color &)
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
SVX_NUM_CHARS_UPPER_LETTER_N
FieldUnit
void SetLabelFollowedBy(const LabelFollowedBy eLabelFollowedBy)
static bool FillObjList(const OUString &rThemeName, std::vector< OUString > &rObjList)
sal_uInt16 nActNumLvl
Definition: numpages.hxx:92
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: numpages.cxx:789
std::unique_ptr< weld::Label > m_xBulColorFT
Definition: numpages.hxx:231
void SetFontSize(const Size &)
ErrCode GetGraphic(Graphic &) const
std::unique_ptr< weld::MenuButton > m_xBitmapMB
Definition: numpages.hxx:242
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
void SetCharFmts(const OUString &rNumName, const OUString &rBulletName)
Definition: numpages.hxx:293
#define SVX_NUM_REL_SIZE_MIN
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: numpages.cxx:2773
const OUString & GetFamilyName() const
const Color & GetBulletColor() const
std::unique_ptr< weld::CustomWeld > m_xExamplesVSWin
Definition: numpages.hxx:175
long GetFirstLineIndent() const
std::unique_ptr< weld::CustomWeld > m_xExamplesVSWin
Definition: numpages.hxx:70
SvxBulletPickTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: numpages.cxx:341
std::unique_ptr< weld::Label > m_xAllLevelFT
Definition: numpages.hxx:235
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: numpages.cxx:228
std::string GetValue
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: numpages.cxx:412
long Height() const
sal_uInt16 GetBulletRelSize() const
#define NUM_VALUSET_COUNT
Definition: numpages.hxx:119
void SetPositionAndSpaceMode(SvxNumPositionAndSpaceMode ePositionAndSpaceMode)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: numpages.cxx:2919
ImplSVEvent * m_pLevelHdlEvent
Definition: numpages.hxx:310
std::unique_ptr< weld::Label > m_xAlign2FT
Definition: numpages.hxx:339
SvxNumSettingsArr_Impl aNumSettingsArrays[NUM_VALUSET_COUNT]
Definition: numpages.hxx:127
const SvxBrushItem * GetBrush() const
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
OUString GetPath() const
const sal_uInt16 * GetLevelVal() const
std::unique_ptr< weld::Label > m_xDistBorderFT
Definition: numpages.hxx:324
void SetNumRule(const SvxNumRule *pNum)
SVX_NUM_NUMBER_NONE
std::unique_ptr< SvxNumRule > pActNum
Definition: numpages.hxx:201
FAMILY_DONTKNOW
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
void SetPrefix(const OUString &rSet)
std::unique_ptr< weld::Widget > m_xAllLevelsFrame
Definition: numpages.hxx:250
IMPL_LINK_NOARG(SvxSingleNumPickTabPage, NumSelectHdl_Impl, SvtValueSet *, void)
Definition: numpages.cxx:295
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
void SetChar(sal_UCS4)
Definition: cuicharmap.cxx:203
const SvxNumberFormat * Get(sal_uInt16 nLevel) const
std::unique_ptr< SvxNumRule > pActNum
Definition: numpages.hxx:61
sal_uInt16 GetValue() const
void SetWeight(FontWeight)
std::unique_ptr< weld::CheckButton > m_xRelativeCB
Definition: numpages.hxx:326
std::unique_ptr< weld::ComboBox > m_xLabelFollowedByLB
Definition: numpages.hxx:336
std::unique_ptr< weld::MetricSpinButton > m_xHeightMF
Definition: numpages.hxx:246
sal_uInt8 GetIncludeUpperLevels() const
static bool BeginLocking(const OUString &rThemeName)
vcl::Font aActBulletFont
Definition: numpages.hxx:213
std::unique_ptr< weld::Label > m_xBitmapFT
Definition: numpages.hxx:241
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
const MapMode & GetMapMode() const
virtual ~SvxSingleNumPickTabPage() override
Definition: numpages.cxx:204
OUString sBulletCharFormatName
Definition: numpages.hxx:97
std::unique_ptr< weld::CustomWeld > m_xPreviewWIN
Definition: numpages.hxx:253
std::unique_ptr< weld::CustomWeld > m_xPreviewWIN
Definition: numpages.hxx:346
const vcl::Font & GetCharFont() const
Definition: cuicharmap.hxx:156
void SetCharSet(rtl_TextEncoding)
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: numpages.cxx:379
static SfxObjectShell * Current()
OUString Name
static const sal_Unicode aBulletTypes[]
Definition: numpages.cxx:121
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: numpages.cxx:1126
void SetIncludeUpperLevels(sal_uInt8 nSet)
static bool EndLocking(const OUString &rThemeName)
OUString GetPath() const
std::unique_ptr< SvxNumRule > pActNum
Definition: numpages.hxx:307
std::unique_ptr< SvxNumRule > pSaveNum
Definition: numpages.hxx:308
static int GetValue(sal_uInt32 i)
virtual ~SvxNumPickTabPage() override
Definition: numpages.cxx:539
#define MAX_BMP_WIDTH
Definition: numpages.cxx:87
static Size GetGraphicSizeMM100(const Graphic *pGraphic)
bool IsAvailable(const OUString &rName) const
std::unique_ptr< weld::Label > m_xStartFT
Definition: numpages.hxx:237
sal_uInt16 nActNumLvl
Definition: numpages.hxx:216
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
Size const & GetOutputSizePixel() const
virtual void Reset(const SfxItemSet *rSet) override
Definition: numpages.cxx:1191
SvxNumType
static OUString GetString(sal_uInt32 i)
OUString PathToFileName() const
std::unique_ptr< weld::CustomWeld > m_xExamplesVSWin
Definition: numpages.hxx:100
Value
std::unique_ptr< weld::Button > m_xBulletPB
Definition: numpages.hxx:240
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
std::unique_ptr< SvxNumRule > pSaveNum
Definition: numpages.hxx:62
sal_uInt16 sal_Unicode
std::unique_ptr< weld::ComboBox > m_xAlign2LB
Definition: numpages.hxx:340
std::unique_ptr< weld::ComboBox > m_xAlignLB
Definition: numpages.hxx:332
std::unique_ptr< weld::MetricSpinButton > m_xListtabMF
Definition: numpages.hxx:338
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
std::unique_ptr< SvxBmpNumValueSet > m_xExamplesVS
Definition: numpages.hxx:174
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: numpages.cxx:1179
#define SAL_MAX_UINT16
const vcl::Font & GetFont() const
SvxNumberingPreview m_aPreviewWIN
Definition: numpages.hxx:320
std::unique_ptr< weld::Label > m_xBulRelSizeFT
Definition: numpages.hxx:233
std::unique_ptr< weld::Label > m_xHeightFT
Definition: numpages.hxx:245
std::unique_ptr< weld::Label > m_xBulletFT
Definition: numpages.hxx:239
std::unique_ptr< weld::TreeView > m_xLevelLB
Definition: numpages.hxx:222
void SetExchangeSupport()
void SetBulletRelSize(sal_uInt16 nSet)
virtual void Reset(const SfxItemSet *rSet) override
Definition: numpages.cxx:846
void SetCharFormatName(const OUString &rSet)
SVX_NUM_ARABIC
std::unique_ptr< weld::Label > m_xSuffixFT
Definition: numpages.hxx:227
FontMetric Get(const OUString &rName, const OUString &rStyleName) const
short GetCharTextDistance() const
sal_uInt16 nNumItemId
Definition: numpages.hxx:132
sal_uInt16 GetExportFormatNumberForShortName(const OUString &rShortName)
std::unique_ptr< SvxNumRule > pSaveNum
Definition: numpages.hxx:130
std::unique_ptr< weld::Button > m_xBtBrowseFile
Definition: numpages.hxx:173
std::unique_ptr< weld::MetricSpinButton > m_xDistBorderMF
Definition: numpages.hxx:325
virtual void Reset(const SfxItemSet *rSet) override
Definition: numpages.cxx:2798
void CheckForStartValue_Impl(sal_uInt16 nNumberingType)
Definition: numpages.cxx:1692
const Graphic * GetGraphic(OUString const &referer=OUString()) const
sal_uInt16 nNumItemId
Definition: numpages.hxx:167
const OUString & GetPrefix() const
std::unique_ptr< weld::CustomWeld > m_xExamplesVSWin
Definition: numpages.hxx:137
const OUString & GetSuffix() const
OUString sBulletChar
Definition: numpages.hxx:47
void SetPitch(FontPitch ePitch)
const LanguageTag & GetLanguageTag() const
std::unique_ptr< SvxNumRule > pActNum
Definition: numpages.hxx:164
std::unique_ptr< weld::Button > m_xStandardPB
Definition: numpages.hxx:345
static long lcl_DrawGraphic(VirtualDevice *pVDev, const SvxNumberFormat &rFmt, long nXStart, long nYMiddle, long nDivision)
Definition: numpages.cxx:2106
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: numpages.cxx:3311
SVX_NUM_BITMAP
void Invert()
SVX_NUM_CHAR_SPECIAL
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
WEIGHT_DONTKNOW
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
static LanguageType getSystemLanguage()
void SetLevel(sal_uInt16 nSet)
void SetModified(bool bRepaint=true)
Definition: numpages.cxx:3301
void SetListtabPos(const long nListtabPos)
bool IsFeatureSupported(SvxNumRuleFlags nFeature) const
IMPL_LINK(SvxNumOptionsTabPage, LevelHdl_Impl, weld::TreeView &, rBox, void)
Definition: numpages.cxx:1550
#define SEARCHPATH_DELIMITER
Definition: numpages.cxx:89
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: numpages.cxx:210
bool IsRTLEnabled() const
#define SAL_MAX_INT32
void Draw(OutputDevice *pOutDev, const Point &rDestPt) const
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: numpages.cxx:595
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
SvxAdjust
virtual void Paint(vcl::RenderContext &rRenderContext, const ::tools::Rectangle &rRect) override
Definition: numpages.cxx:2171
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: numpages.cxx:2729
LabelFollowedBy GetLabelFollowedBy() const
void SetBulletFont(const vcl::Font *pFont)
sal_Int32 GetAbsLSpace() const
void SetMetric(FieldUnit eSet)
Definition: numpages.cxx:2925
std::unique_ptr< weld::Label > m_xCharFmtFT
Definition: numpages.hxx:229
bool IsDark() const
#define SEARCHFILENAME_DELIMITER
Definition: numpages.cxx:90
#define SHOW_BULLET
Definition: numpages.cxx:84
static bool GetGraphicObj(const OUString &rThemeName, sal_uInt32 nPos, Graphic *pGraphic)
static bool InsertURL(const OUString &rThemeName, const OUString &rURL)
SvxSingleNumPickTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: numpages.cxx:162
std::unique_ptr< SvxNumRule > pSaveNum
Definition: numpages.hxx:91
int i
const OUString & GetValue() const
int GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
HTMLMODE_ON
static SvxNumSettings_Impl * lcl_CreateNumSettingsPtr(const Sequence< PropertyValue > &rLevelProps)
Definition: numpages.cxx:94
std::unique_ptr< weld::ComboBox > m_xOrientLB
Definition: numpages.hxx:249
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: numpages.cxx:216
std::unique_ptr< weld::SpinButton > m_xStartED
Definition: numpages.hxx:238
const vcl::Font * GetBulletFont() const
std::unique_ptr< SvxNumRule > pSaveNum
Definition: numpages.hxx:202
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: numpages.cxx:3332
SvxNumberingPreview m_aPreviewWIN
Definition: numpages.hxx:220
OUString MakeNumString(const SvxNodeNum &) const
WEIGHT_NORMAL
const SvxNumberFormat & GetLevel(sal_uInt16 nLevel) const
sal_uInt16 GetLevelCount() const
static sal_uInt32 Count()
static const vcl::Font & lcl_GetDefaultBulletFont()
Definition: numpages.cxx:147
#define SHOW_BITMAP
Definition: numpages.cxx:85
SvxBitmapPickTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: numpages.cxx:729
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: numpages.cxx:551
virtual void Reset(const SfxItemSet *rSet) override
Definition: numpages.cxx:602
std::unique_ptr< weld::MetricSpinButton > m_xIndentAtMF
Definition: numpages.hxx:344
const Size & GetFontSize() const
PITCH_DONTKNOW
std::unique_ptr< weld::Widget > m_xGrid
Definition: numpages.hxx:221
static Reference< XDefaultNumberingProvider > GetNumberingProvider()
std::unique_ptr< SvxNumRule > pActNum
Definition: numpages.hxx:129
std::unique_ptr< weld::Label > m_xIndentFT
Definition: numpages.hxx:327
SvxAdjust GetNumAdjust() const
void SetCharFormatNames(const OUString &rCharName, const OUString &rBulName)
Definition: numpages.hxx:154
std::unique_ptr< weld::Label > m_xPrefixFT
Definition: numpages.hxx:225
std::unique_ptr< weld::MetricSpinButton > m_xIndentMF
Definition: numpages.hxx:328
const AllSettings & GetSettings() const
sal_uInt16 nActNumLvl
Definition: numpages.hxx:166
void SwitchNumberType(sal_uInt8 nType)
To switch between the numbering type 0 - Number; 1 - Bullet; 2 - Bitmap;.
Definition: numpages.cxx:1491
sal_uInt16 GetStart() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
std::unique_ptr< weld::Entry > m_xSuffixED
Definition: numpages.hxx:228
ITALIC_NONE
void ShowControlsDependingOnPosAndSpaceMode()
Definition: numpages.cxx:2893
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
SvxNumSettingsArr_Impl aNumSettingsArr
Definition: numpages.hxx:60
std::unique_ptr< NumValueSet > m_xExamplesVS
Definition: numpages.hxx:99
GPOS_AREA
void SetMetricValue(weld::MetricSpinButton &rField, int nCoreValue, MapUnit eUnit)
void SetTimeout(sal_uInt64 nTimeoutMs)
bool bLabelAlignmentPosAndSpaceModeActive
Definition: numpages.hxx:318
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: numpages.cxx:719
sal_uInt16 nNumItemId
Definition: numpages.hxx:95
static ErrCode Import(SvStream &rIStm, Graphic &rGraphic, ConvertDataFormat nFormat=ConvertDataFormat::Unknown)
SfxItemPool * GetPool() const
std::unique_ptr< weld::Label > m_xListtabFT
Definition: numpages.hxx:337
SVX_NUM_CHARS_LOWER_LETTER_N
ErrCode ExportGraphic(const Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat, const css::uno::Sequence< css::beans::PropertyValue > *pFilterData=nullptr)
const SfxItemSet * GetDialogExampleSet() const
std::vector< OUString > & GetList()
OUString CuiResId(const char *pKey)
Definition: cuiresmgr.cxx:23
void EditModifyHdl_Impl(const weld::Entry *)
Definition: numpages.cxx:2082
virtual ~SvxNumPositionTabPage() override
Definition: numpages.cxx:2523
void SetTitle(const OUString &rNewTitle)
std::unique_ptr< NumValueSet > m_xExamplesVS
Definition: numpages.hxx:69
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: numpages.cxx:368
void SetColor(const Color &)
static bool bLastRelative
Definition: numpages.cxx:92
virtual short run() override
Definition: cuicharmap.cxx:182
SvxNumPickTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: numpages.cxx:490
Point PixelToLogic(const Point &rDevicePt) const
std::unique_ptr< weld::Label > m_xLabelFollowedByFT
Definition: numpages.hxx:335
long GetIndentAt() const
virtual void Reset(const SfxItemSet *rSet) override
Definition: numpages.cxx:419
std::unique_ptr< weld::Label > m_xIndentAtFT
Definition: numpages.hxx:343
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
std::unique_ptr< weld::Label > m_xWidthFT
Definition: numpages.hxx:243
std::unique_ptr< SvxNumRule > pActNum
Definition: numpages.hxx:90
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
bool IsContinuousNumbering() const
std::unique_ptr< weld::Label > m_xOrientFT
Definition: numpages.hxx:248
TabPage for complete numeration.
Definition: numpages.hxx:122
std::unique_ptr< weld::Entry > m_xPrefixED
Definition: numpages.hxx:226
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: numpages.cxx:545
std::unique_ptr< weld::MetricSpinButton > m_xBulRelSizeMF
Definition: numpages.hxx:234
const Size & GetGraphicSize() const
SfxItemState
weld::Entry & rEdit
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: numpages.cxx:562
std::vector< std::unique_ptr< SvxNumSettings_Impl > > SvxNumSettingsArr_Impl
Definition: numpages.hxx:55
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
std::unique_ptr< weld::ComboBox > m_xCharFmtLB
Definition: numpages.hxx:230
#define ERRCODE_NONE
virtual ~SvxBitmapPickTabPage() override
Definition: numpages.cxx:777
#define LINK_TOKEN
unsigned char sal_uInt8
sal_uInt16 nNumItemId
Definition: numpages.hxx:312
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: numpages.cxx:2785
void SetFont(const vcl::Font &rNewFont)
SvxNumPositionTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: numpages.cxx:2456
void clicked()
void SetTransparent(bool bTransparent)
static bool lcl_IsNumFmtSet(SvxNumRule const *pNum, sal_uInt16 nLevelMask)
Definition: numpages.cxx:134
virtual OUString GetCharFormatName() const
sal_uInt16 nActNumLvl
Definition: numpages.hxx:131
SvxNumType nNumberType
Definition: numpages.hxx:43
INetProtocol GetProtocol() const
RET_OK
std::unique_ptr< weld::CheckButton > m_xSameLevelCB
Definition: numpages.hxx:252
OUString GetFileExtension() const
static long lcl_DrawBullet(VirtualDevice *pVDev, const SvxNumberFormat &rFmt, long nXStart, long nYStart, const Size &rSize)
Definition: numpages.cxx:2128
const OUString & GetGalleryPath() const
std::vector< OUString > aGrfNames
Definition: numpages.hxx:162
void SetMetric(FieldUnit eSet)
Definition: numpages.cxx:1115
const OUString PERCENT("Percent")
#define SVX_MAX_NUM
std::unique_ptr< weld::MetricSpinButton > m_xDistNumMF
Definition: numpages.hxx:330
SvxNumOptionsTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: numpages.cxx:1014
void SetInvokeHandler(const Link< Timer *, void > &rLink)
void SetCharFont(const vcl::Font &rFont)
Definition: cuicharmap.cxx:571
void SetLevel(sal_uInt8 nVal)
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
std::unique_ptr< weld::ComboBox > m_xFmtLB
Definition: numpages.hxx:223
long GetListtabPos() const
virtual ~SvxBulletPickTabPage() override
Definition: numpages.cxx:356
sal_Int32 GetFirstLineOffset() const
bool IsShowSymbol() const
#define SVX_DEF_BULLET
long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
sal_Unicode GetBulletChar() const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: numpages.cxx:362
std::unique_ptr< weld::SpinButton > m_xAllLevelNF
Definition: numpages.hxx:236
#define MAX_BMP_HEIGHT
Definition: numpages.cxx:88
DeactivateRC
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: numpages.cxx:262
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: numpages.cxx:830
virtual ~SvxNumOptionsTabPage() override
Definition: numpages.cxx:1107
static GraphicFilter & GetGraphicFilter()
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: numpages.cxx:482
reference_type * get() const
sal_UCS4 GetChar() const
Definition: cuicharmap.cxx:209
#define SAL_WARN(area, stream)
std::unique_ptr< weld::TreeView > m_xLevelLB
Definition: numpages.hxx:321
The main purpose of this dialog is to enable the use of characters that are not easily accessible fro...
Definition: cuicharmap.hxx:71
std::unique_ptr< SvxNumRule > pSaveNum
Definition: numpages.hxx:165
OUString sBulletFont
Definition: numpages.hxx:48
sal_uInt16 nActNumLvl
Definition: numpages.hxx:311
static void GetI18nNumbering(ListBox &rFmtLB, sal_uInt16 nDoNotRemove)
std::unique_ptr< weld::Label > m_xAlignFT
Definition: numpages.hxx:331
std::unique_ptr< weld::Label > m_xAlignedAtFT
Definition: numpages.hxx:341
const FontList * GetFontList() const
std::unique_ptr< ColorListBox > m_xBulColLB
Definition: numpages.hxx:232
void SetNumberingType(SvxNumType nSet)
sal_Int32 const nLength
std::unique_ptr< weld::CheckButton > m_xRatioCB
Definition: numpages.hxx:247
const Size & GetSizePixel() const
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: numpages.cxx:1132
std::unique_ptr< weld::MetricSpinButton > m_xAlignedAtMF
Definition: numpages.hxx:342
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
std::unique_ptr< weld::Label > m_xSeparatorFT
Definition: numpages.hxx:224
sal_Int32 nPos
std::unique_ptr< weld::MetricSpinButton > m_xWidthMF
Definition: numpages.hxx:244
void setWidth(long nWidth)
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
std::unique_ptr< NumValueSet > m_xExamplesVS
Definition: numpages.hxx:136
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
void SetBulletColor(Color nSet)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: numpages.cxx:1172
sal_uInt16 nNumItemId
Definition: numpages.hxx:217
sal_Int16 GetVertOrient() const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: numpages.cxx:783
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: numpages.cxx:823
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
const SvxNumRule * pActNum
const Color & GetFillColor() const
virtual void Reset(const SfxItemSet *rSet) override
Definition: numpages.cxx:269