bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / dlg / BulletAndPositionDlg.cxx
bloba9fc0adcd9b87ce4726ea1bd40de16f65e160457
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/text/HoriOrientation.hpp>
21 #include <com/sun/star/text/VertOrientation.hpp>
22 #include <com/sun/star/text/RelOrientation.hpp>
24 #include <tools/mapunit.hxx>
25 #include <i18nlangtag/languagetag.hxx>
26 #include <i18nlangtag/mslangid.hxx>
27 #include <editeng/numitem.hxx>
28 #include <svl/eitem.hxx>
29 #include <vcl/svapp.hxx>
30 #include <svx/colorbox.hxx>
31 #include <svx/strarray.hxx>
32 #include <svx/gallery.hxx>
33 #include <svl/urihelper.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 <editeng/flstitem.hxx>
40 #include <svx/dlgutil.hxx>
41 #include <svx/xtable.hxx>
42 #include <svx/drawitem.hxx>
43 #include <svx/numvset.hxx>
44 #include <sfx2/htmlmode.hxx>
45 #include <unotools/pathoptions.hxx>
46 #include <svtools/ctrltool.hxx>
47 #include <svtools/unitconv.hxx>
48 #include <editeng/unolingu.hxx>
49 #include <com/sun/star/style/NumberingType.hpp>
50 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 #include <com/sun/star/container/XIndexAccess.hpp>
52 #include <com/sun/star/text/DefaultNumberingProvider.hpp>
53 #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
54 #include <com/sun/star/text/XNumberingFormatter.hpp>
55 #include <com/sun/star/beans/PropertyValue.hpp>
56 #include <comphelper/processfactory.hxx>
57 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
58 #include <svx/dialogs.hrc>
59 #include <svx/svxids.hrc>
61 #include <algorithm>
62 #include <memory>
63 #include <vector>
64 #include <sfx2/opengrf.hxx>
66 #include <strings.hrc>
67 #include <sfx2/request.hxx>
68 #include <svl/aeitem.hxx>
69 #include <svl/stritem.hxx>
70 #include <svl/slstitm.hxx>
71 #include <sfx2/filedlghelper.hxx>
72 #include <svx/gallery1.hxx>
73 #include <svx/galtheme.hxx>
74 #include <unotools/ucbstreamhelper.hxx>
75 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
76 #include <rtl/ustring.h>
77 #include <sal/log.hxx>
78 #include <vcl/cvtgrf.hxx>
79 #include <vcl/graphicfilter.hxx>
80 #include <vcl/virdev.hxx>
81 #include <svx/SvxNumOptionsTabPageHelper.hxx>
82 #include <View.hxx>
83 #include <drawdoc.hxx>
84 #include <cui/cuicharmap.hxx>
85 #include <BulletAndPositionDlg.hxx>
86 #include <sdmod.hxx>
87 #include <sdpage.hxx>
88 #include <sdresid.hxx>
90 #define SHOW_NUMBERING 0
91 #define SHOW_BULLET 1
92 #define SHOW_BITMAP 2
94 #define MAX_BMP_WIDTH 16
95 #define MAX_BMP_HEIGHT 16
97 static bool bLastRelative = false;
99 static const vcl::Font& lcl_GetDefaultBulletFont()
101 static vcl::Font aDefBulletFont = [&]() {
102 vcl::Font tmp("OpenSymbol", "", Size(0, 14));
103 tmp.SetCharSet(RTL_TEXTENCODING_SYMBOL);
104 tmp.SetFamily(FAMILY_DONTKNOW);
105 tmp.SetPitch(PITCH_DONTKNOW);
106 tmp.SetWeight(WEIGHT_DONTKNOW);
107 tmp.SetTransparent(true);
108 return tmp;
109 }();
110 return aDefBulletFont;
113 class SdDrawDocument;
115 SvxBulletAndPositionDlg::SvxBulletAndPositionDlg(weld::Window* pWindow, const SfxItemSet& rSet,
116 ::sd::View* pView)
117 : GenericDialogController(pWindow, "cui/ui/bulletandposition.ui", "BulletAndPosition")
118 , bLastWidthModified(false)
119 , bModified(false)
120 , bPreset(false)
121 , bAutomaticCharStyles(true)
122 , bHTMLMode(false)
123 , bInInitControl(false)
124 , bLabelAlignmentPosAndSpaceModeActive(false)
125 , bApplyToMaster(false)
126 , bIsSlideScope(false)
127 , nBullet(0xff)
128 , nActNumLvl(1)
129 , p_Window(pWindow)
130 , nNumItemId(SID_ATTR_NUMBERING_RULE)
131 , m_xGrid(m_xBuilder->weld_widget("grid2"))
132 , m_xLevelLB(m_xBuilder->weld_tree_view("levellb"))
133 , m_xFmtLB(m_xBuilder->weld_combo_box("numfmtlb"))
134 , m_xPrefixFT(m_xBuilder->weld_label("prefixft"))
135 , m_xPrefixED(m_xBuilder->weld_entry("prefix"))
136 , m_xSuffixFT(m_xBuilder->weld_label("suffixft"))
137 , m_xSuffixED(m_xBuilder->weld_entry("suffix"))
138 , m_xBeforeAfter(m_xBuilder->weld_expander("beforeafter"))
139 , m_xBulColorFT(m_xBuilder->weld_label("colorft"))
140 , m_xBulColLB(new ColorListBox(m_xBuilder->weld_menu_button("color"), pWindow))
141 , m_xBulRelSizeFT(m_xBuilder->weld_label("relsizeft"))
142 , m_xBulRelSizeMF(m_xBuilder->weld_metric_spin_button("relsize", FieldUnit::PERCENT))
143 , m_xStartFT(m_xBuilder->weld_label("startatft"))
144 , m_xStartED(m_xBuilder->weld_spin_button("startat"))
145 , m_xBulletFT(m_xBuilder->weld_label("bulletft"))
146 , m_xBulletPB(m_xBuilder->weld_button("bullet"))
147 , m_xBitmapMB(m_xBuilder->weld_menu_button("bitmap"))
148 , m_xWidthFT(m_xBuilder->weld_label("widthft"))
149 , m_xWidthMF(m_xBuilder->weld_metric_spin_button("widthmf", FieldUnit::CM))
150 , m_xHeightFT(m_xBuilder->weld_label("heightft"))
151 , m_xHeightMF(m_xBuilder->weld_metric_spin_button("heightmf", FieldUnit::CM))
152 , m_xRatioCB(m_xBuilder->weld_check_button("keepratio"))
153 , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN))
154 , m_xDistBorderFT(m_xBuilder->weld_label("indent"))
155 , m_xDistBorderMF(m_xBuilder->weld_metric_spin_button("indentmf", FieldUnit::CM))
156 , m_xRelativeCB(m_xBuilder->weld_check_button("relative"))
157 , m_xIndentFT(m_xBuilder->weld_label("numberingwidth"))
158 , m_xIndentMF(m_xBuilder->weld_metric_spin_button("numberingwidthmf", FieldUnit::CM))
159 , m_xLeftTB(m_xBuilder->weld_toggle_button("left"))
160 , m_xCenterTB(m_xBuilder->weld_toggle_button("center"))
161 , m_xRightTB(m_xBuilder->weld_toggle_button("right"))
162 , m_xSlideRB(m_xBuilder->weld_radio_button("sliderb"))
163 , m_xSelectionRB(m_xBuilder->weld_radio_button("selectionrb"))
164 , m_xApplyToMaster(m_xBuilder->weld_toggle_button("applytomaster"))
166 m_xBulColLB->SetSlotId(SID_ATTR_CHAR_COLOR);
167 m_xBulRelSizeMF->set_min(SVX_NUM_REL_SIZE_MIN, FieldUnit::PERCENT);
168 m_xBulRelSizeMF->set_increments(5, 50, FieldUnit::PERCENT);
169 aActBulletFont = lcl_GetDefaultBulletFont();
171 m_xBulletPB->connect_clicked(LINK(this, SvxBulletAndPositionDlg, BulletHdl_Impl));
172 m_xFmtLB->connect_changed(LINK(this, SvxBulletAndPositionDlg, NumberTypeSelectHdl_Impl));
173 m_xBitmapMB->connect_selected(LINK(this, SvxBulletAndPositionDlg, GraphicHdl_Impl));
174 m_xBitmapMB->connect_toggled(LINK(this, SvxBulletAndPositionDlg, PopupActivateHdl_Impl));
175 m_xLevelLB->set_selection_mode(SelectionMode::Multiple);
176 m_xLevelLB->connect_changed(LINK(this, SvxBulletAndPositionDlg, LevelHdl_Impl));
177 m_xWidthMF->connect_value_changed(LINK(this, SvxBulletAndPositionDlg, SizeHdl_Impl));
178 m_xHeightMF->connect_value_changed(LINK(this, SvxBulletAndPositionDlg, SizeHdl_Impl));
179 m_xRatioCB->connect_toggled(LINK(this, SvxBulletAndPositionDlg, RatioHdl_Impl));
180 m_xStartED->connect_changed(LINK(this, SvxBulletAndPositionDlg, EditModifyHdl_Impl));
181 m_xPrefixED->connect_changed(LINK(this, SvxBulletAndPositionDlg, EditModifyHdl_Impl));
182 m_xSuffixED->connect_changed(LINK(this, SvxBulletAndPositionDlg, EditModifyHdl_Impl));
183 m_xBulRelSizeMF->connect_value_changed(LINK(this, SvxBulletAndPositionDlg, BulRelSizeHdl_Impl));
184 m_xBulColLB->SetSelectHdl(LINK(this, SvxBulletAndPositionDlg, BulColorHdl_Impl));
185 m_xLeftTB->connect_toggled(LINK(this, SvxBulletAndPositionDlg, SelectLeftAlignmentHdl_Impl));
186 m_xCenterTB->connect_toggled(
187 LINK(this, SvxBulletAndPositionDlg, SelectCenterAlignmentHdl_Impl));
188 m_xRightTB->connect_toggled(LINK(this, SvxBulletAndPositionDlg, SelectRightAlignmentHdl_Impl));
189 m_xApplyToMaster->connect_toggled(LINK(this, SvxBulletAndPositionDlg, ApplyToMasterHdl_Impl));
191 aInvalidateTimer.SetInvokeHandler(
192 LINK(this, SvxBulletAndPositionDlg, PreviewInvalidateHdl_Impl));
193 aInvalidateTimer.SetTimeout(50);
195 eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
197 // Fill ListBox with predefined / translated numbering types.
198 sal_uInt32 nCount = SvxNumberingTypeTable::Count();
199 for (sal_uInt32 i = 0; i < nCount; ++i)
201 m_xFmtLB->append(OUString::number(SvxNumberingTypeTable::GetValue(i)),
202 SvxNumberingTypeTable::GetString(i));
205 // Get advanced numbering types from the component.
206 // Watch out for the ugly
207 // 136 == 0x88 == SVX_NUM_BITMAP|0x80 == SVX_NUM_BITMAP|LINK_TOKEN
208 // to not remove that.
209 SvxNumOptionsTabPageHelper::GetI18nNumbering(*m_xFmtLB, (SVX_NUM_BITMAP | LINK_TOKEN));
211 m_xFmtLB->set_active(0);
212 m_xRelativeCB->set_active(true);
214 Link<weld::MetricSpinButton&, void> aLk3
215 = LINK(this, SvxBulletAndPositionDlg, DistanceHdl_Impl);
216 m_xDistBorderMF->connect_value_changed(aLk3);
217 m_xIndentMF->connect_value_changed(aLk3);
219 m_xRelativeCB->connect_toggled(LINK(this, SvxBulletAndPositionDlg, RelativeHdl_Impl));
220 m_xRelativeCB->set_active(bLastRelative);
222 Size aSize(m_xGrid->get_preferred_size());
223 m_xGrid->set_size_request(aSize.Width(), -1);
225 // PageCreated
226 FieldUnit eMetric = pView->GetDoc().GetUIUnit();
227 SfxAllItemSet aSet(*(rSet.GetPool()));
228 aSet.Put(SfxAllEnumItem(SID_METRIC_ITEM, static_cast<sal_uInt16>(eMetric)));
230 const SfxStringItem* pNumCharFmt = aSet.GetItem<SfxStringItem>(SID_NUM_CHAR_FMT, false);
231 const SfxStringItem* pBulletCharFmt = aSet.GetItem<SfxStringItem>(SID_BULLET_CHAR_FMT, false);
232 const SfxAllEnumItem* pMetricItem = aSet.GetItem<SfxAllEnumItem>(SID_METRIC_ITEM, false);
234 if (pNumCharFmt && pBulletCharFmt)
235 SetCharFmts(pNumCharFmt->GetValue(), pBulletCharFmt->GetValue());
237 if (pMetricItem)
238 SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue()));
240 // End PageCreated
242 Reset(&rSet);
244 // ActivatePage part
246 const SfxPoolItem* pItem;
247 const SfxItemSet* pExampleSet = &rSet;
248 sal_uInt16 nTmpNumLvl = 1;
249 if (pExampleSet)
251 if (SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem))
252 bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue();
253 if (SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem))
254 nTmpNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
256 if (SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
258 pSaveNum.reset(new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()));
261 bModified = (!pActNum->Get(0) || bPreset);
262 if (*pActNum != *pSaveNum || nActNumLvl != nTmpNumLvl)
264 nActNumLvl = nTmpNumLvl;
265 sal_uInt16 nMask = 1;
266 if (nActNumLvl == SAL_MAX_UINT16)
267 m_xLevelLB->select(pActNum->GetLevelCount());
268 if (nActNumLvl != SAL_MAX_UINT16)
270 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
272 if (nActNumLvl & nMask)
273 m_xLevelLB->select(i);
274 nMask <<= 1;
277 *pActNum = *pSaveNum;
279 m_xRelativeCB->set_sensitive(nActNumLvl != 1);
281 InitPosAndSpaceMode();
282 InitControls();
285 m_aPreviewWIN.SetLevel(nActNumLvl);
286 m_aPreviewWIN.Invalidate();
288 // End of the ActivatePage part
291 SvxBulletAndPositionDlg::~SvxBulletAndPositionDlg() {}
293 void SvxBulletAndPositionDlg::dispose()
295 m_xPreviewWIN.reset();
296 m_xBulColLB.reset();
297 pActNum.reset();
298 pSaveNum.reset();
301 void SvxBulletAndPositionDlg::SetMetric(FieldUnit eMetric)
303 if (eMetric == FieldUnit::MM)
305 m_xWidthMF->set_digits(1);
306 m_xHeightMF->set_digits(1);
307 m_xDistBorderMF->set_digits(1);
308 m_xIndentMF->set_digits(1);
310 m_xWidthMF->set_unit(eMetric);
311 m_xHeightMF->set_unit(eMetric);
312 m_xDistBorderMF->set_unit(eMetric);
313 m_xIndentMF->set_unit(eMetric);
316 SfxItemSet* SvxBulletAndPositionDlg::GetOutputItemSet(SfxItemSet* pSet)
318 pSet->Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL, nActNumLvl));
319 if (bModified && pActNum)
321 *pSaveNum = *pActNum;
322 pSet->Put(SvxNumBulletItem(*pSaveNum, nNumItemId));
323 pSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, false));
325 return pSet;
328 bool SvxBulletAndPositionDlg::IsApplyToMaster() { return bApplyToMaster; }
329 bool SvxBulletAndPositionDlg::IsSlideScope() { return m_xSlideRB->get_active(); }
331 void SvxBulletAndPositionDlg::Reset(const SfxItemSet* rSet)
333 const SfxPoolItem* pItem;
334 // in Draw the item exists as WhichId, in Writer only as SlotId
335 SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem);
336 if (eState != SfxItemState::SET)
338 nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE);
339 eState = rSet->GetItemState(nNumItemId, false, &pItem);
341 if (eState != SfxItemState::SET)
343 pItem = &static_cast<const SvxNumBulletItem&>(rSet->Get(nNumItemId));
344 eState = SfxItemState::SET;
347 DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
348 pSaveNum.reset(new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()));
350 // insert levels
351 if (!m_xLevelLB->n_children())
353 for (sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++)
354 m_xLevelLB->append_text(OUString::number(i));
355 if (pSaveNum->GetLevelCount() > 1)
357 OUString sEntry = "1 - " + OUString::number(pSaveNum->GetLevelCount());
358 m_xLevelLB->append_text(sEntry);
359 m_xLevelLB->select_text(sEntry);
361 else
362 m_xLevelLB->select(0);
364 else
365 m_xLevelLB->select(m_xLevelLB->n_children() - 1);
367 sal_uInt16 nMask = 1;
368 m_xLevelLB->unselect_all();
369 if (nActNumLvl == SAL_MAX_UINT16)
371 m_xLevelLB->select(pSaveNum->GetLevelCount());
373 else
375 for (sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++)
377 if (nActNumLvl & nMask)
378 m_xLevelLB->select(i);
379 nMask <<= 1;
383 if (!pActNum)
384 pActNum.reset(new SvxNumRule(*pSaveNum));
385 else if (*pSaveNum != *pActNum)
386 *pActNum = *pSaveNum;
387 m_aPreviewWIN.SetNumRule(pActNum.get());
389 SfxObjectShell* pShell;
390 if (SfxItemState::SET == rSet->GetItemState(SID_HTML_MODE, false, &pItem)
391 || (nullptr != (pShell = SfxObjectShell::Current())
392 && nullptr != (pItem = pShell->GetItem(SID_HTML_MODE))))
394 sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
395 bHTMLMode = 0 != (nHtmlMode & HTMLMODE_ON);
398 bool bContinuous = pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS);
400 // again misusage: in Draw there is numeration only until the bitmap
401 // without SVX_NUM_NUMBER_NONE
402 //remove types that are unsupported by Draw/Impress
403 if (!bContinuous)
405 sal_Int32 nFmtCount = m_xFmtLB->get_count();
406 for (sal_Int32 i = nFmtCount; i; i--)
408 sal_uInt16 nEntryData = m_xFmtLB->get_id(i - 1).toUInt32();
409 if (/*SVX_NUM_NUMBER_NONE == nEntryData ||*/
410 (SVX_NUM_BITMAP | LINK_TOKEN) == nEntryData)
411 m_xFmtLB->remove(i - 1);
414 //one must be enabled
415 if (!pActNum->IsFeatureSupported(SvxNumRuleFlags::ENABLE_LINKED_BMP))
417 auto nPos = m_xFmtLB->find_id(OUString::number(SVX_NUM_BITMAP | LINK_TOKEN));
418 if (nPos != -1)
419 m_xFmtLB->remove(nPos);
421 else if (!pActNum->IsFeatureSupported(SvxNumRuleFlags::ENABLE_EMBEDDED_BMP))
423 auto nPos = m_xFmtLB->find_id(OUString::number(SVX_NUM_BITMAP));
424 if (nPos != -1)
425 m_xFmtLB->remove(nPos);
428 // MegaHack: because of a not-fixable 'design mistake/error' in Impress
429 // delete all kinds of numeric enumerations
430 if (pActNum->IsFeatureSupported(SvxNumRuleFlags::NO_NUMBERS))
432 sal_Int32 nFmtCount = m_xFmtLB->get_count();
433 for (sal_Int32 i = nFmtCount; i; i--)
435 sal_uInt16 nEntryData = m_xFmtLB->get_id(i - 1).toUInt32();
436 if (/*nEntryData >= SVX_NUM_CHARS_UPPER_LETTER &&*/ nEntryData <= SVX_NUM_NUMBER_NONE)
437 m_xFmtLB->remove(i - 1);
441 InitPosAndSpaceMode();
443 InitControls();
444 bModified = false;
447 void SvxBulletAndPositionDlg::InitControls()
449 bInInitControl = true;
451 const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive && m_xRelativeCB->get_sensitive()
452 && m_xRelativeCB->get_active();
453 const bool bSingleSelection
454 = m_xLevelLB->count_selected_rows() == 1 && SAL_MAX_UINT16 != nActNumLvl;
456 m_xDistBorderMF->set_sensitive(!bLabelAlignmentPosAndSpaceModeActive
457 && (bSingleSelection || bRelative));
458 m_xDistBorderFT->set_sensitive(!bLabelAlignmentPosAndSpaceModeActive
459 && (bSingleSelection || bRelative));
461 bool bShowBullet = true;
462 bool bShowBitmap = true;
463 bool bSameType = true;
464 bool bSameStart = true;
465 bool bSamePrefix = true;
466 bool bSameSuffix = true;
467 bool bAllLevel = true;
468 bool bSameCharFmt = true;
469 bool bSameVOrient = true;
470 bool bSameSize = true;
471 bool bSameBulColor = true;
472 bool bSameBulRelSize = true;
473 bool bSameDistBorderNum = !bLabelAlignmentPosAndSpaceModeActive;
474 bool bSetDistEmpty = false;
475 bool bSameIndent = !bLabelAlignmentPosAndSpaceModeActive;
477 const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM];
478 OUString sFirstCharFmt;
479 sal_Int16 eFirstOrient = text::VertOrientation::NONE;
480 SvxAdjust eFirstAdjust = SvxAdjust::Left;
481 Size aFirstSize(0, 0);
482 sal_uInt16 nMask = 1;
483 sal_uInt16 nLvl = SAL_MAX_UINT16;
484 sal_uInt16 nHighestLevel = 0;
485 (void)nHighestLevel;
487 bool bBullColor = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR);
488 bool bBullRelSize = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE);
489 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
491 if (nActNumLvl & nMask)
493 aNumFmtArr[i] = &pActNum->GetLevel(i);
494 bShowBullet &= aNumFmtArr[i]->GetNumberingType() == SVX_NUM_CHAR_SPECIAL;
495 bShowBitmap &= (aNumFmtArr[i]->GetNumberingType() & (~LINK_TOKEN)) == SVX_NUM_BITMAP;
496 eFirstAdjust = aNumFmtArr[i]->GetNumAdjust();
497 if (SAL_MAX_UINT16 == nLvl)
499 nLvl = i;
500 sFirstCharFmt = aNumFmtArr[i]->GetCharFormatName();
501 eFirstOrient = aNumFmtArr[i]->GetVertOrient();
502 if (bShowBitmap)
503 aFirstSize = aNumFmtArr[i]->GetGraphicSize();
505 if (i > nLvl)
507 bSameType
508 &= aNumFmtArr[i]->GetNumberingType() == aNumFmtArr[nLvl]->GetNumberingType();
509 bSameStart = aNumFmtArr[i]->GetStart() == aNumFmtArr[nLvl]->GetStart();
511 bSamePrefix = aNumFmtArr[i]->GetPrefix() == aNumFmtArr[nLvl]->GetPrefix();
512 bSameSuffix = aNumFmtArr[i]->GetSuffix() == aNumFmtArr[nLvl]->GetSuffix();
513 bAllLevel &= aNumFmtArr[i]->GetIncludeUpperLevels()
514 == aNumFmtArr[nLvl]->GetIncludeUpperLevels();
515 bSameCharFmt &= sFirstCharFmt == aNumFmtArr[i]->GetCharFormatName();
516 bSameVOrient &= eFirstOrient == aNumFmtArr[i]->GetVertOrient();
517 //bSameAdjust &= eFirstAdjust == aNumFmtArr[i]->GetNumAdjust();
518 if (bShowBitmap && bSameSize)
519 bSameSize &= aNumFmtArr[i]->GetGraphicSize() == aFirstSize;
520 bSameBulColor
521 &= aNumFmtArr[i]->GetBulletColor() == aNumFmtArr[nLvl]->GetBulletColor();
522 bSameBulRelSize
523 &= aNumFmtArr[i]->GetBulletRelSize() == aNumFmtArr[nLvl]->GetBulletRelSize();
524 bSameIndent //?
525 &= aNumFmtArr[i]->GetFirstLineOffset()
526 == aNumFmtArr[nLvl]->GetFirstLineOffset();
528 nHighestLevel = i;
530 else
531 aNumFmtArr[i] = nullptr;
533 nMask <<= 1;
535 SwitchNumberType(bShowBullet ? 1 : bShowBitmap ? 2 : 0);
537 sal_uInt16 nNumberingType;
538 if (nLvl != SAL_MAX_UINT16)
539 nNumberingType = aNumFmtArr[nLvl]->GetNumberingType();
540 else
542 nNumberingType = SVX_NUM_NUMBER_NONE;
543 bAllLevel = false;
544 bSameBulRelSize = false;
545 bSameBulColor = false;
546 bSameStart = false;
547 bSamePrefix = false;
548 bSameSuffix = false;
551 CheckForStartValue_Impl(nNumberingType);
553 if (bShowBitmap)
555 if (bSameSize)
557 SetMetricValue(*m_xHeightMF, aFirstSize.Height(), eCoreUnit);
558 SetMetricValue(*m_xWidthMF, aFirstSize.Width(), eCoreUnit);
560 else
562 m_xHeightMF->set_text("");
563 m_xWidthMF->set_text("");
567 if (bSameType)
569 sal_uInt16 nLBData = nNumberingType;
570 m_xFmtLB->set_active_id(OUString::number(nLBData));
572 else
573 m_xFmtLB->set_active(-1);
575 if (bBullRelSize)
577 if (bSameBulRelSize)
578 m_xBulRelSizeMF->set_value(aNumFmtArr[nLvl]->GetBulletRelSize(), FieldUnit::PERCENT);
579 else
580 m_xBulRelSizeMF->set_text("");
582 if (bBullColor)
584 if (bSameBulColor)
585 m_xBulColLB->SelectEntry(aNumFmtArr[nLvl]->GetBulletColor());
586 else
587 m_xBulColLB->SetNoSelection();
589 switch (nBullet)
591 case SHOW_NUMBERING:
592 if (bSameStart)
594 m_xStartED->set_value(aNumFmtArr[nLvl]->GetStart());
596 else
597 m_xStartED->set_text("");
598 break;
599 case SHOW_BULLET:
600 break;
601 case SHOW_BITMAP:
602 break;
605 switch (eFirstAdjust)
607 case SvxAdjust::Left:
608 m_xLeftTB->set_active(true);
609 m_xCenterTB->set_active(false);
610 m_xRightTB->set_active(false);
611 break;
612 case SvxAdjust::Center:
613 m_xLeftTB->set_active(false);
614 m_xCenterTB->set_active(true);
615 m_xRightTB->set_active(false);
616 break;
617 case SvxAdjust::Right:
618 m_xLeftTB->set_active(false);
619 m_xCenterTB->set_active(false);
620 m_xRightTB->set_active(true);
621 break;
622 default:
623 break;
626 if (bSamePrefix)
627 m_xPrefixED->set_text(aNumFmtArr[nLvl]->GetPrefix());
628 else
629 m_xPrefixED->set_text("");
630 if (bSameSuffix)
631 m_xSuffixED->set_text(aNumFmtArr[nLvl]->GetSuffix());
632 else
633 m_xSuffixED->set_text("");
635 if (bSameDistBorderNum)
637 long nDistBorderNum;
638 if (bRelative)
640 nDistBorderNum = static_cast<long>(aNumFmtArr[nLvl]->GetAbsLSpace())
641 + aNumFmtArr[nLvl]->GetFirstLineOffset();
642 if (nLvl)
643 nDistBorderNum -= static_cast<long>(aNumFmtArr[nLvl - 1]->GetAbsLSpace())
644 + aNumFmtArr[nLvl - 1]->GetFirstLineOffset();
646 else
648 nDistBorderNum = static_cast<long>(aNumFmtArr[nLvl]->GetAbsLSpace())
649 + aNumFmtArr[nLvl]->GetFirstLineOffset();
651 SetMetricValue(*m_xDistBorderMF, nDistBorderNum, eCoreUnit);
653 else
654 bSetDistEmpty = true;
656 if (bSetDistEmpty)
657 m_xDistBorderMF->set_text("");
659 if (bSameIndent)
660 SetMetricValue(*m_xIndentMF, -aNumFmtArr[nLvl]->GetFirstLineOffset(), eCoreUnit);
661 else
662 m_xIndentMF->set_text("");
664 m_xSelectionRB->set_active(true);
666 m_aPreviewWIN.SetLevel(nActNumLvl);
667 m_aPreviewWIN.Invalidate();
668 bInInitControl = false;
671 // 0 - Number; 1 - Bullet; 2 - Bitmap
672 void SvxBulletAndPositionDlg::SwitchNumberType(sal_uInt8 nType)
674 if (nBullet == nType)
675 return;
676 nBullet = nType;
677 bool bBullet = (nType == SHOW_BULLET);
678 bool bBitmap = (nType == SHOW_BITMAP);
679 bool bEnableBitmap = (nType == SHOW_BITMAP);
680 bool bNumeric = !(bBitmap || bBullet);
681 m_xPrefixFT->set_visible(bNumeric);
682 m_xPrefixED->set_visible(bNumeric);
683 m_xSuffixFT->set_visible(bNumeric);
684 m_xSuffixED->set_visible(bNumeric);
685 m_xBeforeAfter->set_visible(bNumeric);
687 m_xStartFT->set_visible(!(bBullet || bBitmap));
688 m_xStartED->set_visible(!(bBullet || bBitmap));
690 m_xBulletFT->set_visible(bBullet);
691 m_xBulletPB->set_visible(bBullet);
692 bool bBullColor = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR);
693 m_xBulColorFT->set_visible(!bBitmap && bBullColor);
694 m_xBulColLB->set_visible(!bBitmap && bBullColor);
695 bool bBullResSize = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE);
696 m_xBulRelSizeFT->set_visible(!bBitmap && bBullResSize);
697 m_xBulRelSizeMF->set_visible(!bBitmap && bBullResSize);
699 m_xBitmapMB->set_visible(bBitmap);
701 m_xWidthFT->set_visible(bBitmap);
702 m_xWidthMF->set_visible(bBitmap);
703 m_xHeightFT->set_visible(bBitmap);
704 m_xHeightMF->set_visible(bBitmap);
705 m_xRatioCB->set_visible(bBitmap);
707 m_xWidthFT->set_sensitive(bEnableBitmap);
708 m_xWidthMF->set_sensitive(bEnableBitmap);
709 m_xHeightFT->set_sensitive(bEnableBitmap);
710 m_xHeightMF->set_sensitive(bEnableBitmap);
711 m_xRatioCB->set_sensitive(bEnableBitmap);
714 void SvxBulletAndPositionDlg::CheckForStartValue_Impl(sal_uInt16 nNumberingType)
716 bool bIsNull = m_xStartED->get_value() == 0;
717 bool bNoZeroAllowed = nNumberingType < SVX_NUM_ARABIC
718 || SVX_NUM_CHARS_UPPER_LETTER_N == nNumberingType
719 || SVX_NUM_CHARS_LOWER_LETTER_N == nNumberingType;
720 m_xStartED->set_min(bNoZeroAllowed ? 1 : 0);
721 if (bIsNull && bNoZeroAllowed)
722 EditModifyHdl_Impl(*m_xStartED);
725 IMPL_LINK(SvxBulletAndPositionDlg, LevelHdl_Impl, weld::TreeView&, rBox, void)
727 sal_uInt16 nSaveNumLvl = nActNumLvl;
728 nActNumLvl = 0;
729 auto aSelectedRows = rBox.get_selected_rows();
730 if (std::find(aSelectedRows.begin(), aSelectedRows.end(), pActNum->GetLevelCount())
731 != aSelectedRows.end()
732 && (aSelectedRows.size() == 1 || nSaveNumLvl != 0xffff))
734 nActNumLvl = 0xFFFF;
735 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
736 rBox.unselect(i);
738 else if (!aSelectedRows.empty())
740 sal_uInt16 nMask = 1;
741 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
743 if (std::find(aSelectedRows.begin(), aSelectedRows.end(), i) != aSelectedRows.end())
744 nActNumLvl |= nMask;
745 nMask <<= 1;
747 rBox.unselect(pActNum->GetLevelCount());
749 else
751 nActNumLvl = nSaveNumLvl;
752 sal_uInt16 nMask = 1;
753 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
755 if (nActNumLvl & nMask)
757 rBox.select(i);
758 break;
760 nMask <<= 1;
763 InitControls();
766 IMPL_LINK_NOARG(SvxBulletAndPositionDlg, PreviewInvalidateHdl_Impl, Timer*, void)
768 m_aPreviewWIN.Invalidate();
771 IMPL_LINK(SvxBulletAndPositionDlg, NumberTypeSelectHdl_Impl, weld::ComboBox&, rBox, void)
773 OUString sSelectStyle;
774 bool bBmp = false;
775 sal_uInt16 nMask = 1;
776 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
778 if (nActNumLvl & nMask)
780 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
781 // PAGEDESC does not exist
782 SvxNumType nNumType = static_cast<SvxNumType>(rBox.get_active_id().toUInt32());
783 aNumFmt.SetNumberingType(nNumType);
784 sal_uInt16 nNumberingType = aNumFmt.GetNumberingType();
785 if (SVX_NUM_BITMAP == (nNumberingType & (~LINK_TOKEN)))
787 bBmp |= nullptr != aNumFmt.GetBrush();
788 aNumFmt.SetIncludeUpperLevels(0);
789 aNumFmt.SetSuffix("");
790 aNumFmt.SetPrefix("");
791 if (!bBmp)
792 aNumFmt.SetGraphic("");
793 pActNum->SetLevel(i, aNumFmt);
794 SwitchNumberType(SHOW_BITMAP);
796 else if (SVX_NUM_CHAR_SPECIAL == nNumberingType)
798 aNumFmt.SetIncludeUpperLevels(0);
799 aNumFmt.SetSuffix("");
800 aNumFmt.SetPrefix("");
801 if (!aNumFmt.GetBulletFont())
802 aNumFmt.SetBulletFont(&aActBulletFont);
803 if (!aNumFmt.GetBulletChar())
804 aNumFmt.SetBulletChar(SVX_DEF_BULLET);
805 pActNum->SetLevel(i, aNumFmt);
806 SwitchNumberType(SHOW_BULLET);
807 // allocation of the drawing pattern is automatic
808 if (bAutomaticCharStyles)
810 sSelectStyle = m_sBulletCharFormatName;
813 else
815 aNumFmt.SetPrefix(m_xPrefixED->get_text());
816 aNumFmt.SetSuffix(m_xSuffixED->get_text());
817 SwitchNumberType(SHOW_NUMBERING);
818 pActNum->SetLevel(i, aNumFmt);
819 CheckForStartValue_Impl(nNumberingType);
821 // allocation of the drawing pattern is automatic
822 if (bAutomaticCharStyles)
824 sSelectStyle = m_sNumCharFmtName;
828 nMask <<= 1;
831 SetModified();
834 IMPL_LINK(SvxBulletAndPositionDlg, BulColorHdl_Impl, ColorListBox&, rColorBox, void)
836 Color nSetColor = rColorBox.GetSelectEntryColor();
838 sal_uInt16 nMask = 1;
839 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
841 if (nActNumLvl & nMask)
843 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
844 aNumFmt.SetBulletColor(nSetColor);
845 pActNum->SetLevel(i, aNumFmt);
847 nMask <<= 1;
849 SetModified();
852 IMPL_LINK(SvxBulletAndPositionDlg, BulRelSizeHdl_Impl, weld::MetricSpinButton&, rField, void)
854 sal_uInt16 nRelSize = rField.get_value(FieldUnit::PERCENT);
856 sal_uInt16 nMask = 1;
857 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
859 if (nActNumLvl & nMask)
861 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
862 aNumFmt.SetBulletRelSize(nRelSize);
863 pActNum->SetLevel(i, aNumFmt);
865 nMask <<= 1;
867 SetModified();
870 IMPL_LINK(SvxBulletAndPositionDlg, GraphicHdl_Impl, const OString&, rIdent, void)
872 OUString aGrfName;
873 Size aSize;
874 bool bSucc(false);
875 SvxOpenGraphicDialog aGrfDlg(SdResId(RID_SVXSTR_EDIT_GRAPHIC), p_Window);
877 OString sNumber;
878 if (rIdent.startsWith("gallery", &sNumber))
880 auto idx = sNumber.toUInt32();
881 if (idx < aGrfNames.size())
883 aGrfName = aGrfNames[idx];
884 Graphic aGraphic;
885 if (GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, idx, &aGraphic))
887 aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
888 bSucc = true;
892 else if (rIdent == "fromfile")
894 aGrfDlg.EnableLink(false);
895 aGrfDlg.AsLink(false);
896 if (!aGrfDlg.Execute())
898 // memorize selected filter
899 aGrfName = aGrfDlg.GetPath();
901 Graphic aGraphic;
902 if (!aGrfDlg.GetGraphic(aGraphic))
904 aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic);
905 bSucc = true;
909 if (bSucc)
911 aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit));
913 sal_uInt16 nMask = 1;
914 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
916 if (nActNumLvl & nMask)
918 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
919 aNumFmt.SetCharFormatName(m_sNumCharFmtName);
920 aNumFmt.SetGraphic(aGrfName);
922 // set size for a later comparison
923 const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
924 // initiate asynchronous loading
925 sal_Int16 eOrient = aNumFmt.GetVertOrient();
926 aNumFmt.SetGraphicBrush(pBrushItem, &aSize, &eOrient);
927 aInitSize[i] = aNumFmt.GetGraphicSize();
929 pActNum->SetLevel(i, aNumFmt);
931 nMask <<= 1;
933 m_xRatioCB->set_sensitive(true);
934 m_xWidthFT->set_sensitive(true);
935 m_xHeightFT->set_sensitive(true);
936 m_xWidthMF->set_sensitive(true);
937 m_xHeightMF->set_sensitive(true);
938 SetMetricValue(*m_xWidthMF, aSize.Width(), eCoreUnit);
939 SetMetricValue(*m_xHeightMF, aSize.Height(), eCoreUnit);
941 SetModified();
942 //needed due to asynchronous loading of graphics in the SvxBrushItem
943 aInvalidateTimer.Start();
947 IMPL_LINK_NOARG(SvxBulletAndPositionDlg, PopupActivateHdl_Impl, weld::ToggleButton&, void)
949 if (!m_xGalleryMenu)
951 m_xGalleryMenu = m_xBuilder->weld_menu("gallerysubmenu");
952 weld::WaitObject aWait(p_Window);
954 if (GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames))
956 GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS);
958 Graphic aGraphic;
959 OUString sGrfName;
960 ScopedVclPtrInstance<VirtualDevice> pVD;
961 size_t i = 0;
962 for (auto& grfName : aGrfNames)
964 sGrfName = grfName;
965 OUString sItemId = "gallery" + OUString::number(i);
966 INetURLObject aObj(sGrfName);
967 if (aObj.GetProtocol() == INetProtocol::File)
968 sGrfName = aObj.PathToFileName();
969 if (GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, i, &aGraphic))
971 BitmapEx aBitmap(aGraphic.GetBitmapEx());
972 Size aSize(aBitmap.GetSizePixel());
973 if (aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT)
975 bool bWidth = aSize.Width() > aSize.Height();
976 double nScale
977 = bWidth ? double(MAX_BMP_WIDTH) / static_cast<double>(aSize.Width())
978 : double(MAX_BMP_HEIGHT) / static_cast<double>(aSize.Height());
979 aBitmap.Scale(nScale, nScale);
981 pVD->SetOutputSizePixel(aBitmap.GetSizePixel(), false);
982 pVD->DrawBitmapEx(Point(), aBitmap);
983 m_xGalleryMenu->append(sItemId, sGrfName, *pVD);
985 else
987 m_xGalleryMenu->append(sItemId, sGrfName);
989 ++i;
991 GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS);
996 IMPL_LINK_NOARG(SvxBulletAndPositionDlg, BulletHdl_Impl, weld::Button&, void)
998 SvxCharacterMap aMap(p_Window, nullptr, nullptr);
1000 sal_uInt16 nMask = 1;
1001 const vcl::Font* pFmtFont = nullptr;
1002 bool bSameBullet = true;
1003 sal_Unicode cBullet = 0;
1004 bool bFirst = true;
1005 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1007 if (nActNumLvl & nMask)
1009 const SvxNumberFormat& rCurFmt = pActNum->GetLevel(i);
1010 if (bFirst)
1012 cBullet = rCurFmt.GetBulletChar();
1014 else if (rCurFmt.GetBulletChar() != cBullet)
1016 bSameBullet = false;
1017 break;
1019 if (!pFmtFont)
1020 pFmtFont = rCurFmt.GetBulletFont();
1021 bFirst = false;
1023 nMask <<= 1;
1026 if (pFmtFont)
1027 aMap.SetCharFont(*pFmtFont);
1028 else
1029 aMap.SetCharFont(aActBulletFont);
1030 if (bSameBullet)
1031 aMap.SetChar(cBullet);
1032 if (aMap.run() == RET_OK)
1034 // change Font Numrules
1035 aActBulletFont = aMap.GetCharFont();
1037 sal_uInt16 _nMask = 1;
1038 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1040 if (nActNumLvl & _nMask)
1042 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1043 aNumFmt.SetBulletFont(&aActBulletFont);
1044 aNumFmt.SetBulletChar(static_cast<sal_Unicode>(aMap.GetChar()));
1045 pActNum->SetLevel(i, aNumFmt);
1047 _nMask <<= 1;
1050 SetModified();
1054 IMPL_LINK(SvxBulletAndPositionDlg, SizeHdl_Impl, weld::MetricSpinButton&, rField, void)
1056 bool bWidth = &rField == m_xWidthMF.get();
1057 bLastWidthModified = bWidth;
1058 bool bRatio = m_xRatioCB->get_active();
1059 long nWidthVal
1060 = static_cast<long>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::MM_100TH)));
1061 long nHeightVal
1062 = static_cast<long>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FieldUnit::MM_100TH)));
1063 nWidthVal = OutputDevice::LogicToLogic(nWidthVal, MapUnit::Map100thMM, eCoreUnit);
1064 nHeightVal = OutputDevice::LogicToLogic(nHeightVal, MapUnit::Map100thMM, eCoreUnit);
1065 double fSizeRatio;
1067 bool bRepaint = false;
1068 sal_uInt16 nMask = 1;
1069 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1071 if (nActNumLvl & nMask)
1073 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1074 if (SVX_NUM_BITMAP == (aNumFmt.GetNumberingType() & (~LINK_TOKEN)))
1076 Size aSize(aNumFmt.GetGraphicSize());
1077 Size aSaveSize(aSize);
1079 if (aInitSize[i].Height())
1080 fSizeRatio = static_cast<double>(aInitSize[i].Width())
1081 / static_cast<double>(aInitSize[i].Height());
1082 else
1083 fSizeRatio = double(1);
1085 if (bWidth)
1087 long nDelta = nWidthVal - aInitSize[i].Width();
1088 aSize.setWidth(nWidthVal);
1089 if (bRatio)
1091 aSize.setHeight(
1092 aInitSize[i].Height()
1093 + static_cast<long>(static_cast<double>(nDelta) / fSizeRatio));
1094 m_xHeightMF->set_value(m_xHeightMF->normalize(OutputDevice::LogicToLogic(
1095 aSize.Height(), eCoreUnit, MapUnit::Map100thMM)),
1096 FieldUnit::MM_100TH);
1099 else
1101 long nDelta = nHeightVal - aInitSize[i].Height();
1102 aSize.setHeight(nHeightVal);
1103 if (bRatio)
1105 aSize.setWidth(
1106 aInitSize[i].Width()
1107 + static_cast<long>(static_cast<double>(nDelta) * fSizeRatio));
1108 m_xWidthMF->set_value(m_xWidthMF->normalize(OutputDevice::LogicToLogic(
1109 aSize.Width(), eCoreUnit, MapUnit::Map100thMM)),
1110 FieldUnit::MM_100TH);
1113 const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
1114 sal_Int16 eOrient = aNumFmt.GetVertOrient();
1115 if (aSize != aSaveSize)
1116 bRepaint = true;
1117 aNumFmt.SetGraphicBrush(pBrushItem, &aSize, &eOrient);
1118 pActNum->SetLevel(i, aNumFmt);
1121 nMask <<= 1;
1123 SetModified(bRepaint);
1126 IMPL_LINK(SvxBulletAndPositionDlg, RatioHdl_Impl, weld::ToggleButton&, rBox, void)
1128 if (rBox.get_active())
1130 if (bLastWidthModified)
1131 SizeHdl_Impl(*m_xWidthMF);
1132 else
1133 SizeHdl_Impl(*m_xHeightMF);
1137 IMPL_LINK(SvxBulletAndPositionDlg, SelectLeftAlignmentHdl_Impl, weld::ToggleButton&, rButton, void)
1139 if (rButton.get_active())
1141 SetAlignmentHdl_Impl(SvxAdjust::Left);
1143 m_xCenterTB->set_active(false);
1144 m_xRightTB->set_active(false);
1146 SetModified();
1150 IMPL_LINK(SvxBulletAndPositionDlg, SelectCenterAlignmentHdl_Impl, weld::ToggleButton&, rButton,
1151 void)
1153 if (rButton.get_active())
1155 SetAlignmentHdl_Impl(SvxAdjust::Center);
1157 m_xLeftTB->set_active(false);
1158 m_xRightTB->set_active(false);
1160 SetModified();
1164 IMPL_LINK(SvxBulletAndPositionDlg, SelectRightAlignmentHdl_Impl, weld::ToggleButton&, rButton, void)
1166 if (rButton.get_active())
1168 SetAlignmentHdl_Impl(SvxAdjust::Right);
1170 m_xLeftTB->set_active(false);
1171 m_xCenterTB->set_active(false);
1173 SetModified();
1177 void SvxBulletAndPositionDlg::SetAlignmentHdl_Impl(SvxAdjust eAdjust)
1179 sal_uInt16 nMask = 1;
1180 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1182 if (nActNumLvl & nMask)
1184 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1185 aNumFmt.SetNumAdjust(eAdjust);
1186 pActNum->SetLevel(i, aNumFmt);
1188 nMask <<= 1;
1192 IMPL_LINK(SvxBulletAndPositionDlg, ApplyToMasterHdl_Impl, weld::ToggleButton&, rButton, void)
1194 bApplyToMaster = rButton.get_active();
1197 IMPL_LINK(SvxBulletAndPositionDlg, EditModifyHdl_Impl, weld::Entry&, rEdit, void)
1199 EditModifyHdl_Impl(&rEdit);
1202 IMPL_LINK(SvxBulletAndPositionDlg, DistanceHdl_Impl, weld::MetricSpinButton&, rFld, void)
1204 if (bInInitControl)
1205 return;
1206 long nValue = GetCoreValue(rFld, eCoreUnit);
1207 sal_uInt16 nMask = 1;
1208 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1210 if (nActNumLvl & nMask)
1212 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1213 if (&rFld == m_xDistBorderMF.get())
1215 if (m_xRelativeCB->get_active())
1217 if (0 == i)
1219 auto const nTmp = aNumFmt.GetFirstLineOffset();
1220 aNumFmt.SetAbsLSpace(nValue - nTmp);
1222 else
1224 long nTmp = pActNum->GetLevel(i - 1).GetAbsLSpace()
1225 + pActNum->GetLevel(i - 1).GetFirstLineOffset()
1226 - pActNum->GetLevel(i).GetFirstLineOffset();
1228 aNumFmt.SetAbsLSpace(nValue + nTmp);
1231 else
1233 aNumFmt.SetAbsLSpace(nValue - aNumFmt.GetFirstLineOffset());
1236 else if (&rFld == m_xIndentMF.get())
1238 // together with the FirstLineOffset the AbsLSpace must be changed, too
1239 long nDiff = nValue + aNumFmt.GetFirstLineOffset();
1240 auto const nAbsLSpace = aNumFmt.GetAbsLSpace();
1241 aNumFmt.SetAbsLSpace(nAbsLSpace + nDiff);
1242 aNumFmt.SetFirstLineOffset(-nValue);
1245 pActNum->SetLevel(i, aNumFmt);
1247 nMask <<= 1;
1250 SetModified();
1251 if (!m_xDistBorderMF->get_sensitive())
1253 m_xDistBorderMF->set_text("");
1257 IMPL_LINK(SvxBulletAndPositionDlg, RelativeHdl_Impl, weld::ToggleButton&, rBox, void)
1259 bool bOn = rBox.get_active();
1260 bool bSingleSelection = m_xLevelLB->count_selected_rows() == 1 && SAL_MAX_UINT16 != nActNumLvl;
1261 bool bSetValue = false;
1262 long nValue = 0;
1263 if (bOn || bSingleSelection)
1265 sal_uInt16 nMask = 1;
1266 bool bFirst = true;
1267 bSetValue = true;
1268 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1270 if (nActNumLvl & nMask)
1272 const SvxNumberFormat& rNumFmt = pActNum->GetLevel(i);
1273 if (bFirst)
1275 nValue = rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset();
1276 if (bOn && i)
1277 nValue -= (pActNum->GetLevel(i - 1).GetAbsLSpace()
1278 + pActNum->GetLevel(i - 1).GetFirstLineOffset());
1280 else
1281 bSetValue = nValue
1282 == (rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset())
1283 - (pActNum->GetLevel(i - 1).GetAbsLSpace()
1284 + pActNum->GetLevel(i - 1).GetFirstLineOffset());
1285 bFirst = false;
1287 nMask <<= 1;
1290 if (bSetValue)
1291 SetMetricValue(*m_xDistBorderMF, nValue, eCoreUnit);
1292 else
1293 m_xDistBorderMF->set_text("");
1294 m_xDistBorderMF->set_sensitive(bOn || bSingleSelection);
1295 m_xDistBorderFT->set_sensitive(bOn || bSingleSelection);
1296 bLastRelative = bOn;
1299 void SvxBulletAndPositionDlg::EditModifyHdl_Impl(const weld::Entry* pEdit)
1301 bool bPrefix = pEdit == m_xPrefixED.get();
1302 bool bSuffix = pEdit == m_xSuffixED.get();
1303 bool bStart = pEdit == m_xStartED.get();
1304 sal_uInt16 nMask = 1;
1305 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
1307 if (nActNumLvl & nMask)
1309 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1310 if (bPrefix)
1311 aNumFmt.SetPrefix(m_xPrefixED->get_text());
1312 else if (bSuffix)
1313 aNumFmt.SetSuffix(m_xSuffixED->get_text());
1314 else if (bStart)
1315 aNumFmt.SetStart(m_xStartED->get_value());
1316 pActNum->SetLevel(i, aNumFmt);
1318 nMask <<= 1;
1320 SetModified();
1323 void SvxBulletAndPositionDlg::SetModified(bool bRepaint)
1325 bModified = true;
1326 if (bRepaint)
1328 m_aPreviewWIN.SetLevel(nActNumLvl);
1329 m_aPreviewWIN.Invalidate();
1333 void SvxBulletAndPositionDlg::InitPosAndSpaceMode()
1335 if (pActNum == nullptr)
1337 SAL_WARN("cui.tabpages", "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of "
1338 "method -> <pAktNum> has to be already set!");
1339 return;
1342 SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode = SvxNumberFormat::LABEL_ALIGNMENT;
1343 sal_uInt16 nMask = 1;
1344 for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i)
1346 if (nActNumLvl & nMask)
1348 SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
1349 ePosAndSpaceMode = aNumFmt.GetPositionAndSpaceMode();
1350 if (ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT)
1352 break;
1355 nMask <<= 1;
1358 bLabelAlignmentPosAndSpaceModeActive = ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT;
1361 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */