File: | home/maarten/src/libreoffice/core/include/rtl/ref.hxx |
Warning: | line 192, column 9 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 <tools/mapunit.hxx> | |||
21 | #include <tools/urlobj.hxx> | |||
22 | #include <editeng/numitem.hxx> | |||
23 | #include <svl/eitem.hxx> | |||
24 | #include <svl/itempool.hxx> | |||
25 | #include <svx/colorbox.hxx> | |||
26 | #include <svx/strarray.hxx> | |||
27 | #include <svx/gallery.hxx> | |||
28 | #include <editeng/brushitem.hxx> | |||
29 | #include <svl/intitem.hxx> | |||
30 | #include <vcl/graph.hxx> | |||
31 | #include <svtools/unitconv.hxx> | |||
32 | #include <svx/svxids.hrc> | |||
33 | ||||
34 | #include <algorithm> | |||
35 | #include <memory> | |||
36 | #include <vector> | |||
37 | #include <sfx2/opengrf.hxx> | |||
38 | ||||
39 | #include <strings.hrc> | |||
40 | #include <svl/aeitem.hxx> | |||
41 | #include <svl/stritem.hxx> | |||
42 | #include <sal/log.hxx> | |||
43 | #include <vcl/virdev.hxx> | |||
44 | #include <svx/SvxNumOptionsTabPageHelper.hxx> | |||
45 | #include <View.hxx> | |||
46 | #include <drawdoc.hxx> | |||
47 | #include <cui/cuicharmap.hxx> | |||
48 | #include <BulletAndPositionDlg.hxx> | |||
49 | #include <sdresid.hxx> | |||
50 | ||||
51 | #define SHOW_NUMBERING0 0 | |||
52 | #define SHOW_BULLET1 1 | |||
53 | #define SHOW_BITMAP2 2 | |||
54 | ||||
55 | #define MAX_BMP_WIDTH16 16 | |||
56 | #define MAX_BMP_HEIGHT16 16 | |||
57 | ||||
58 | static bool bLastRelative = false; | |||
59 | ||||
60 | static const vcl::Font& lcl_GetDefaultBulletFont() | |||
61 | { | |||
62 | static vcl::Font aDefBulletFont = [&]() { | |||
63 | vcl::Font tmp("OpenSymbol", "", Size(0, 14)); | |||
64 | tmp.SetCharSet(RTL_TEXTENCODING_SYMBOL(((rtl_TextEncoding) 10))); | |||
65 | tmp.SetFamily(FAMILY_DONTKNOW); | |||
66 | tmp.SetPitch(PITCH_DONTKNOW); | |||
67 | tmp.SetWeight(WEIGHT_DONTKNOW); | |||
68 | tmp.SetTransparent(true); | |||
69 | return tmp; | |||
70 | }(); | |||
71 | return aDefBulletFont; | |||
72 | } | |||
73 | ||||
74 | class SdDrawDocument; | |||
75 | ||||
76 | SvxBulletAndPositionDlg::SvxBulletAndPositionDlg(weld::Window* pWindow, const SfxItemSet& rSet, | |||
77 | const ::sd::View* pView) | |||
78 | : GenericDialogController(pWindow, "cui/ui/bulletandposition.ui", "BulletAndPosition") | |||
79 | , rFirstStateSet(rSet) | |||
80 | , bLastWidthModified(false) | |||
81 | , bModified(false) | |||
82 | , bInInitControl(false) | |||
83 | , bLabelAlignmentPosAndSpaceModeActive(false) | |||
84 | , bApplyToMaster(false) | |||
85 | , nBullet(0xff) | |||
86 | , nActNumLvl(1) | |||
87 | , p_Window(pWindow) | |||
88 | , nNumItemId(SID_ATTR_NUMBERING_RULE( 10000 + 855 )) | |||
89 | , m_xGrid(m_xBuilder->weld_widget("grid2")) | |||
90 | , m_xLevelLB(m_xBuilder->weld_tree_view("levellb")) | |||
91 | , m_xFmtLB(m_xBuilder->weld_combo_box("numfmtlb")) | |||
92 | , m_xPrefixFT(m_xBuilder->weld_label("prefixft")) | |||
93 | , m_xPrefixED(m_xBuilder->weld_entry("prefix")) | |||
94 | , m_xSuffixFT(m_xBuilder->weld_label("suffixft")) | |||
95 | , m_xSuffixED(m_xBuilder->weld_entry("suffix")) | |||
96 | , m_xBeforeAfter(m_xBuilder->weld_frame("beforeafter")) | |||
97 | , m_xBulColorFT(m_xBuilder->weld_label("colorft")) | |||
98 | , m_xBulColLB(new ColorListBox(m_xBuilder->weld_menu_button("color"), pWindow)) | |||
99 | , m_xBulRelSizeFT(m_xBuilder->weld_label("relsizeft")) | |||
100 | , m_xBulRelSizeMF(m_xBuilder->weld_metric_spin_button("relsize", FieldUnit::PERCENT)) | |||
101 | , m_xStartFT(m_xBuilder->weld_label("startatft")) | |||
102 | , m_xStartED(m_xBuilder->weld_spin_button("startat")) | |||
103 | , m_xBulletFT(m_xBuilder->weld_label("bulletft")) | |||
104 | , m_xBulletPB(m_xBuilder->weld_button("bullet")) | |||
105 | , m_xBitmapMB(m_xBuilder->weld_menu_button("bitmap")) | |||
106 | , m_xWidthFT(m_xBuilder->weld_label("widthft")) | |||
107 | , m_xWidthMF(m_xBuilder->weld_metric_spin_button("widthmf", FieldUnit::CM)) | |||
108 | , m_xHeightFT(m_xBuilder->weld_label("heightft")) | |||
109 | , m_xHeightMF(m_xBuilder->weld_metric_spin_button("heightmf", FieldUnit::CM)) | |||
110 | , m_xRatioCB(m_xBuilder->weld_check_button("keepratio")) | |||
111 | , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN)) | |||
112 | , m_xDistBorderFT(m_xBuilder->weld_label("indent")) | |||
113 | , m_xDistBorderMF(m_xBuilder->weld_metric_spin_button("indentmf", FieldUnit::CM)) | |||
114 | , m_xRelativeCB(m_xBuilder->weld_check_button("relative")) | |||
115 | , m_xIndentFT(m_xBuilder->weld_label("numberingwidth")) | |||
116 | , m_xIndentMF(m_xBuilder->weld_metric_spin_button("numberingwidthmf", FieldUnit::CM)) | |||
117 | , m_xLeftTB(m_xBuilder->weld_toggle_button("left")) | |||
118 | , m_xCenterTB(m_xBuilder->weld_toggle_button("center")) | |||
119 | , m_xRightTB(m_xBuilder->weld_toggle_button("right")) | |||
120 | , m_xSlideRB(m_xBuilder->weld_radio_button("sliderb")) | |||
121 | , m_xSelectionRB(m_xBuilder->weld_radio_button("selectionrb")) | |||
122 | , m_xApplyToMaster(m_xBuilder->weld_toggle_button("applytomaster")) | |||
123 | , m_xReset(m_xBuilder->weld_button("reset")) | |||
124 | { | |||
125 | m_xBulColLB->SetSlotId(SID_ATTR_CHAR_COLOR( 10000 + 17 )); | |||
126 | m_xBulRelSizeMF->set_min(SVX_NUM_REL_SIZE_MIN25, FieldUnit::PERCENT); | |||
127 | m_xBulRelSizeMF->set_increments(5, 50, FieldUnit::PERCENT); | |||
128 | aActBulletFont = lcl_GetDefaultBulletFont(); | |||
129 | ||||
130 | m_xBulletPB->connect_clicked(LINK(this, SvxBulletAndPositionDlg, BulletHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubBulletHdl_Impl )); | |||
131 | m_xFmtLB->connect_changed(LINK(this, SvxBulletAndPositionDlg, NumberTypeSelectHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubNumberTypeSelectHdl_Impl )); | |||
132 | m_xBitmapMB->connect_selected(LINK(this, SvxBulletAndPositionDlg, GraphicHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubGraphicHdl_Impl )); | |||
133 | m_xBitmapMB->connect_toggled(LINK(this, SvxBulletAndPositionDlg, PopupActivateHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubPopupActivateHdl_Impl )); | |||
134 | m_xLevelLB->set_selection_mode(SelectionMode::Multiple); | |||
135 | m_xLevelLB->connect_changed(LINK(this, SvxBulletAndPositionDlg, LevelHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubLevelHdl_Impl )); | |||
136 | m_xWidthMF->connect_value_changed(LINK(this, SvxBulletAndPositionDlg, SizeHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubSizeHdl_Impl )); | |||
137 | m_xHeightMF->connect_value_changed(LINK(this, SvxBulletAndPositionDlg, SizeHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubSizeHdl_Impl )); | |||
138 | m_xRatioCB->connect_toggled(LINK(this, SvxBulletAndPositionDlg, RatioHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubRatioHdl_Impl )); | |||
139 | m_xStartED->connect_changed(LINK(this, SvxBulletAndPositionDlg, EditModifyHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubEditModifyHdl_Impl )); | |||
140 | m_xPrefixED->connect_changed(LINK(this, SvxBulletAndPositionDlg, EditModifyHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubEditModifyHdl_Impl )); | |||
141 | m_xSuffixED->connect_changed(LINK(this, SvxBulletAndPositionDlg, EditModifyHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubEditModifyHdl_Impl )); | |||
142 | m_xBulRelSizeMF->connect_value_changed(LINK(this, SvxBulletAndPositionDlg, BulRelSizeHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubBulRelSizeHdl_Impl )); | |||
143 | m_xBulColLB->SetSelectHdl(LINK(this, SvxBulletAndPositionDlg, BulColorHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubBulColorHdl_Impl )); | |||
144 | m_xLeftTB->connect_toggled(LINK(this, SvxBulletAndPositionDlg, SelectLeftAlignmentHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubSelectLeftAlignmentHdl_Impl )); | |||
145 | m_xCenterTB->connect_toggled( | |||
146 | LINK(this, SvxBulletAndPositionDlg, SelectCenterAlignmentHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubSelectCenterAlignmentHdl_Impl )); | |||
147 | m_xRightTB->connect_toggled(LINK(this, SvxBulletAndPositionDlg, SelectRightAlignmentHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubSelectRightAlignmentHdl_Impl )); | |||
148 | m_xApplyToMaster->connect_toggled(LINK(this, SvxBulletAndPositionDlg, ApplyToMasterHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubApplyToMasterHdl_Impl )); | |||
149 | m_xReset->connect_clicked(LINK(this, SvxBulletAndPositionDlg, ResetHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubResetHdl_Impl )); | |||
150 | ||||
151 | aInvalidateTimer.SetInvokeHandler( | |||
152 | LINK(this, SvxBulletAndPositionDlg, PreviewInvalidateHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubPreviewInvalidateHdl_Impl )); | |||
153 | aInvalidateTimer.SetTimeout(50); | |||
154 | ||||
155 | eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE( 10000 + 855 ))); | |||
156 | ||||
157 | // Fill ListBox with predefined / translated numbering types. | |||
158 | sal_uInt32 nCount = SvxNumberingTypeTable::Count(); | |||
159 | for (sal_uInt32 i = 0; i < nCount; ++i) | |||
160 | { | |||
161 | m_xFmtLB->append(OUString::number(SvxNumberingTypeTable::GetValue(i)), | |||
162 | SvxNumberingTypeTable::GetString(i)); | |||
163 | } | |||
164 | ||||
165 | // Get advanced numbering types from the component. | |||
166 | // Watch out for the ugly | |||
167 | // 136 == 0x88 == SVX_NUM_BITMAP|0x80 == SVX_NUM_BITMAP|LINK_TOKEN | |||
168 | // to not remove that. | |||
169 | SvxNumOptionsTabPageHelper::GetI18nNumbering(*m_xFmtLB, (SVX_NUM_BITMAP | LINK_TOKEN0x80)); | |||
170 | ||||
171 | m_xFmtLB->set_active(0); | |||
172 | m_xRelativeCB->set_active(true); | |||
173 | ||||
174 | Link<weld::MetricSpinButton&, void> aLk3 | |||
175 | = LINK(this, SvxBulletAndPositionDlg, DistanceHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubDistanceHdl_Impl ); | |||
176 | m_xDistBorderMF->connect_value_changed(aLk3); | |||
177 | m_xIndentMF->connect_value_changed(aLk3); | |||
178 | ||||
179 | m_xRelativeCB->connect_toggled(LINK(this, SvxBulletAndPositionDlg, RelativeHdl_Impl)::tools::detail::makeLink( ::tools::detail::castTo<SvxBulletAndPositionDlg *>(this), &SvxBulletAndPositionDlg::LinkStubRelativeHdl_Impl )); | |||
180 | m_xRelativeCB->set_active(bLastRelative); | |||
181 | ||||
182 | Size aSize(m_xGrid->get_preferred_size()); | |||
183 | m_xGrid->set_size_request(aSize.Width(), -1); | |||
184 | ||||
185 | // PageCreated | |||
186 | FieldUnit eMetric = pView->GetDoc().GetUIUnit(); | |||
187 | SfxAllItemSet aSet(*(rSet.GetPool())); | |||
188 | aSet.Put(SfxUInt16Item(SID_METRIC_ITEMTypedWhichId<SfxUInt16Item>( 10000 + 1024 ), static_cast<sal_uInt16>(eMetric))); | |||
189 | ||||
190 | const SfxStringItem* pNumCharFmt = aSet.GetItem<SfxStringItem>(SID_NUM_CHAR_FMT( 10000 + 1025 ), false); | |||
191 | const SfxStringItem* pBulletCharFmt = aSet.GetItem<SfxStringItem>(SID_BULLET_CHAR_FMT( 10000 + 1026 ), false); | |||
192 | const SfxUInt16Item* pMetricItem = aSet.GetItem<SfxUInt16Item>(SID_METRIC_ITEMTypedWhichId<SfxUInt16Item>( 10000 + 1024 ), false); | |||
193 | ||||
194 | if (pNumCharFmt && pBulletCharFmt) | |||
195 | SetCharFmts(pNumCharFmt->GetValue(), pBulletCharFmt->GetValue()); | |||
196 | ||||
197 | if (pMetricItem) | |||
198 | SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue())); | |||
199 | ||||
200 | // End PageCreated | |||
201 | ||||
202 | Reset(&rSet); | |||
203 | ||||
204 | // ActivatePage part | |||
205 | ||||
206 | const SfxPoolItem* pItem; | |||
207 | const SfxItemSet* pExampleSet = &rSet; | |||
208 | sal_uInt16 nTmpNumLvl = 1; | |||
209 | bool bPreset = false; | |||
210 | if (pExampleSet) | |||
211 | { | |||
212 | if (SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET( 10000 + 856 ), false, &pItem)) | |||
213 | bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | |||
214 | if (SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL( 10000 + 859 ), false, &pItem)) | |||
215 | nTmpNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); | |||
216 | } | |||
217 | if (SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) | |||
218 | { | |||
219 | pSaveNum.reset(new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule())); | |||
220 | } | |||
221 | ||||
222 | bModified = (!pActNum->Get(0) || bPreset); | |||
223 | if (*pActNum != *pSaveNum || nActNumLvl != nTmpNumLvl) | |||
224 | { | |||
225 | nActNumLvl = nTmpNumLvl; | |||
226 | sal_uInt16 nMask = 1; | |||
227 | if (nActNumLvl == SAL_MAX_UINT16((sal_uInt16) 0xFFFF)) | |||
228 | m_xLevelLB->select(pActNum->GetLevelCount()); | |||
229 | if (nActNumLvl != SAL_MAX_UINT16((sal_uInt16) 0xFFFF)) | |||
230 | { | |||
231 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
232 | { | |||
233 | if (nActNumLvl & nMask) | |||
234 | m_xLevelLB->select(i); | |||
235 | nMask <<= 1; | |||
236 | } | |||
237 | } | |||
238 | *pActNum = *pSaveNum; | |||
239 | ||||
240 | m_xRelativeCB->set_sensitive(nActNumLvl != 1); | |||
241 | ||||
242 | InitPosAndSpaceMode(); | |||
243 | InitControls(); | |||
244 | } | |||
245 | ||||
246 | m_aPreviewWIN.SetLevel(nActNumLvl); | |||
247 | m_aPreviewWIN.Invalidate(); | |||
248 | ||||
249 | // End of the ActivatePage part | |||
250 | } | |||
251 | ||||
252 | SvxBulletAndPositionDlg::~SvxBulletAndPositionDlg() {} | |||
253 | ||||
254 | void SvxBulletAndPositionDlg::SetMetric(FieldUnit eMetric) | |||
255 | { | |||
256 | if (eMetric == FieldUnit::MM) | |||
257 | { | |||
258 | m_xWidthMF->set_digits(1); | |||
259 | m_xHeightMF->set_digits(1); | |||
260 | m_xDistBorderMF->set_digits(1); | |||
261 | m_xIndentMF->set_digits(1); | |||
262 | } | |||
263 | m_xWidthMF->set_unit(eMetric); | |||
264 | m_xHeightMF->set_unit(eMetric); | |||
265 | m_xDistBorderMF->set_unit(eMetric); | |||
266 | m_xIndentMF->set_unit(eMetric); | |||
267 | } | |||
268 | ||||
269 | SfxItemSet* SvxBulletAndPositionDlg::GetOutputItemSet(SfxItemSet* pSet) | |||
270 | { | |||
271 | pSet->Put(SfxUInt16Item(SID_PARAM_CUR_NUM_LEVEL( 10000 + 859 ), nActNumLvl)); | |||
272 | if (bModified && pActNum) | |||
273 | { | |||
274 | *pSaveNum = *pActNum; | |||
275 | pSet->Put(SvxNumBulletItem(*pSaveNum, nNumItemId)); | |||
276 | pSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET( 10000 + 856 ), false)); | |||
277 | } | |||
278 | return pSet; | |||
279 | }; | |||
280 | ||||
281 | bool SvxBulletAndPositionDlg::IsApplyToMaster() const { return bApplyToMaster; } | |||
282 | bool SvxBulletAndPositionDlg::IsSlideScope() const { return m_xSlideRB->get_active(); } | |||
283 | ||||
284 | void SvxBulletAndPositionDlg::Reset(const SfxItemSet* rSet) | |||
285 | { | |||
286 | const SfxPoolItem* pItem; | |||
287 | // in Draw the item exists as WhichId, in Writer only as SlotId | |||
288 | SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE( 10000 + 855 ), false, &pItem); | |||
289 | if (eState != SfxItemState::SET) | |||
290 | { | |||
291 | nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE( 10000 + 855 )); | |||
292 | eState = rSet->GetItemState(nNumItemId, false, &pItem); | |||
293 | ||||
294 | if (eState != SfxItemState::SET) | |||
295 | { | |||
296 | pItem = &static_cast<const SvxNumBulletItem&>(rSet->Get(nNumItemId)); | |||
297 | eState = SfxItemState::SET; | |||
298 | } | |||
299 | } | |||
300 | DBG_ASSERT(eState == SfxItemState::SET, "no item found!")do { if (true && (!(eState == SfxItemState::SET))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/dlg/BulletAndPositionDlg.cxx" ":" "300" ": "), "%s", "no item found!"); } } while (false); | |||
301 | pSaveNum.reset(new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule())); | |||
302 | ||||
303 | // insert levels | |||
304 | if (!m_xLevelLB->n_children()) | |||
305 | { | |||
306 | for (sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++) | |||
307 | m_xLevelLB->append_text(OUString::number(i)); | |||
308 | if (pSaveNum->GetLevelCount() > 1) | |||
309 | { | |||
310 | OUString sEntry = "1 - " + OUString::number(pSaveNum->GetLevelCount()); | |||
311 | m_xLevelLB->append_text(sEntry); | |||
312 | m_xLevelLB->select_text(sEntry); | |||
313 | } | |||
314 | else | |||
315 | m_xLevelLB->select(0); | |||
316 | } | |||
317 | else | |||
318 | m_xLevelLB->select(m_xLevelLB->n_children() - 1); | |||
319 | ||||
320 | sal_uInt16 nMask = 1; | |||
321 | m_xLevelLB->unselect_all(); | |||
322 | if (nActNumLvl == SAL_MAX_UINT16((sal_uInt16) 0xFFFF)) | |||
323 | { | |||
324 | m_xLevelLB->select(pSaveNum->GetLevelCount()); | |||
325 | } | |||
326 | else | |||
327 | { | |||
328 | for (sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++) | |||
329 | { | |||
330 | if (nActNumLvl & nMask) | |||
331 | m_xLevelLB->select(i); | |||
332 | nMask <<= 1; | |||
333 | } | |||
334 | } | |||
335 | ||||
336 | if (!pActNum) | |||
337 | pActNum.reset(new SvxNumRule(*pSaveNum)); | |||
338 | else if (*pSaveNum != *pActNum) | |||
339 | *pActNum = *pSaveNum; | |||
340 | m_aPreviewWIN.SetNumRule(pActNum.get()); | |||
341 | ||||
342 | bool bContinuous = pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS); | |||
343 | ||||
344 | // again misusage: in Draw there is numeration only until the bitmap | |||
345 | // without SVX_NUM_NUMBER_NONE | |||
346 | //remove types that are unsupported by Draw/Impress | |||
347 | if (!bContinuous) | |||
348 | { | |||
349 | sal_Int32 nFmtCount = m_xFmtLB->get_count(); | |||
350 | for (sal_Int32 i = nFmtCount; i; i--) | |||
351 | { | |||
352 | sal_uInt16 nEntryData = m_xFmtLB->get_id(i - 1).toUInt32(); | |||
353 | if (/*SVX_NUM_NUMBER_NONE == nEntryData ||*/ | |||
354 | (SVX_NUM_BITMAP | LINK_TOKEN0x80) == nEntryData) | |||
355 | m_xFmtLB->remove(i - 1); | |||
356 | } | |||
357 | } | |||
358 | //one must be enabled | |||
359 | if (!pActNum->IsFeatureSupported(SvxNumRuleFlags::ENABLE_LINKED_BMP)) | |||
360 | { | |||
361 | auto nPos = m_xFmtLB->find_id(OUString::number(SVX_NUM_BITMAP | LINK_TOKEN0x80)); | |||
362 | if (nPos != -1) | |||
363 | m_xFmtLB->remove(nPos); | |||
364 | } | |||
365 | else if (!pActNum->IsFeatureSupported(SvxNumRuleFlags::ENABLE_EMBEDDED_BMP)) | |||
366 | { | |||
367 | auto nPos = m_xFmtLB->find_id(OUString::number(SVX_NUM_BITMAP)); | |||
368 | if (nPos != -1) | |||
369 | m_xFmtLB->remove(nPos); | |||
370 | } | |||
371 | ||||
372 | // MegaHack: because of a not-fixable 'design mistake/error' in Impress | |||
373 | // delete all kinds of numeric enumerations | |||
374 | if (pActNum->IsFeatureSupported(SvxNumRuleFlags::NO_NUMBERS)) | |||
375 | { | |||
376 | sal_Int32 nFmtCount = m_xFmtLB->get_count(); | |||
377 | for (sal_Int32 i = nFmtCount; i; i--) | |||
378 | { | |||
379 | sal_uInt16 nEntryData = m_xFmtLB->get_id(i - 1).toUInt32(); | |||
380 | if (/*nEntryData >= SVX_NUM_CHARS_UPPER_LETTER &&*/ nEntryData <= SVX_NUM_NUMBER_NONE) | |||
381 | m_xFmtLB->remove(i - 1); | |||
382 | } | |||
383 | } | |||
384 | ||||
385 | InitPosAndSpaceMode(); | |||
386 | ||||
387 | InitControls(); | |||
388 | bModified = false; | |||
389 | } | |||
390 | ||||
391 | void SvxBulletAndPositionDlg::InitControls() | |||
392 | { | |||
393 | bInInitControl = true; | |||
394 | ||||
395 | const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive && m_xRelativeCB->get_sensitive() | |||
396 | && m_xRelativeCB->get_active(); | |||
397 | const bool bSingleSelection | |||
398 | = m_xLevelLB->count_selected_rows() == 1 && SAL_MAX_UINT16((sal_uInt16) 0xFFFF) != nActNumLvl; | |||
399 | ||||
400 | m_xDistBorderMF->set_sensitive(!bLabelAlignmentPosAndSpaceModeActive | |||
401 | && (bSingleSelection || bRelative)); | |||
402 | m_xDistBorderFT->set_sensitive(!bLabelAlignmentPosAndSpaceModeActive | |||
403 | && (bSingleSelection || bRelative)); | |||
404 | ||||
405 | bool bShowBullet = true; | |||
406 | bool bShowBitmap = true; | |||
407 | bool bSameType = true; | |||
408 | bool bSameStart = true; | |||
409 | bool bSamePrefix = true; | |||
410 | bool bSameSuffix = true; | |||
411 | bool bSameSize = true; | |||
412 | bool bSameBulColor = true; | |||
413 | bool bSameBulRelSize = true; | |||
414 | bool bSameDistBorderNum = !bLabelAlignmentPosAndSpaceModeActive; | |||
415 | bool bSetDistEmpty = false; | |||
416 | bool bSameIndent = !bLabelAlignmentPosAndSpaceModeActive; | |||
417 | ||||
418 | const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM10]; | |||
419 | OUString sFirstCharFmt; | |||
420 | SvxAdjust eFirstAdjust = SvxAdjust::Left; | |||
421 | Size aFirstSize(0, 0); | |||
422 | sal_uInt16 nMask = 1; | |||
423 | sal_uInt16 nLvl = SAL_MAX_UINT16((sal_uInt16) 0xFFFF); | |||
424 | ||||
425 | bool bBullColor = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR); | |||
426 | bool bBullRelSize = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE); | |||
427 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
428 | { | |||
429 | aNumFmtArr[i] = &pActNum->GetLevel(i); | |||
430 | ||||
431 | if (nActNumLvl & nMask) | |||
432 | { | |||
433 | bShowBullet &= aNumFmtArr[i]->GetNumberingType() == SVX_NUM_CHAR_SPECIAL; | |||
434 | bShowBitmap &= (aNumFmtArr[i]->GetNumberingType() & (~LINK_TOKEN0x80)) == SVX_NUM_BITMAP; | |||
435 | eFirstAdjust = aNumFmtArr[i]->GetNumAdjust(); | |||
436 | if (SAL_MAX_UINT16((sal_uInt16) 0xFFFF) == nLvl) | |||
437 | { | |||
438 | nLvl = i; | |||
439 | sFirstCharFmt = aNumFmtArr[i]->GetCharFormatName(); | |||
440 | if (bShowBitmap) | |||
441 | aFirstSize = aNumFmtArr[i]->GetGraphicSize(); | |||
442 | } | |||
443 | if (i > nLvl) | |||
444 | { | |||
445 | bSameType | |||
446 | &= aNumFmtArr[i]->GetNumberingType() == aNumFmtArr[nLvl]->GetNumberingType(); | |||
447 | bSameStart = aNumFmtArr[i]->GetStart() == aNumFmtArr[nLvl]->GetStart(); | |||
448 | ||||
449 | bSamePrefix = aNumFmtArr[i]->GetPrefix() == aNumFmtArr[nLvl]->GetPrefix(); | |||
450 | bSameSuffix = aNumFmtArr[i]->GetSuffix() == aNumFmtArr[nLvl]->GetSuffix(); | |||
451 | //bSameAdjust &= eFirstAdjust == aNumFmtArr[i]->GetNumAdjust(); | |||
452 | if (bShowBitmap && bSameSize) | |||
453 | bSameSize &= aNumFmtArr[i]->GetGraphicSize() == aFirstSize; | |||
454 | bSameBulColor | |||
455 | &= aNumFmtArr[i]->GetBulletColor() == aNumFmtArr[nLvl]->GetBulletColor(); | |||
456 | bSameBulRelSize | |||
457 | &= aNumFmtArr[i]->GetBulletRelSize() == aNumFmtArr[nLvl]->GetBulletRelSize(); | |||
458 | bSameIndent //? | |||
459 | &= aNumFmtArr[i]->GetFirstLineOffset() | |||
460 | == aNumFmtArr[nLvl]->GetFirstLineOffset(); | |||
461 | } | |||
462 | } | |||
463 | ||||
464 | nMask <<= 1; | |||
465 | } | |||
466 | SwitchNumberType(bShowBullet ? 1 : bShowBitmap ? 2 : 0); | |||
467 | ||||
468 | sal_uInt16 nNumberingType; | |||
469 | if (nLvl != SAL_MAX_UINT16((sal_uInt16) 0xFFFF)) | |||
470 | nNumberingType = aNumFmtArr[nLvl]->GetNumberingType(); | |||
471 | else | |||
472 | { | |||
473 | nNumberingType = SVX_NUM_NUMBER_NONE; | |||
474 | bSameDistBorderNum = false; | |||
475 | bSameIndent = false; | |||
476 | bSameBulRelSize = false; | |||
477 | bSameBulColor = false; | |||
478 | bSameStart = false; | |||
479 | bSamePrefix = false; | |||
480 | bSameSuffix = false; | |||
481 | } | |||
482 | ||||
483 | CheckForStartValue_Impl(nNumberingType); | |||
484 | ||||
485 | if (bShowBitmap) | |||
486 | { | |||
487 | if (bSameSize) | |||
488 | { | |||
489 | SetMetricValue(*m_xHeightMF, aFirstSize.Height(), eCoreUnit); | |||
490 | SetMetricValue(*m_xWidthMF, aFirstSize.Width(), eCoreUnit); | |||
491 | } | |||
492 | else | |||
493 | { | |||
494 | m_xHeightMF->set_text(""); | |||
495 | m_xWidthMF->set_text(""); | |||
496 | } | |||
497 | } | |||
498 | ||||
499 | if (bSameType) | |||
500 | { | |||
501 | sal_uInt16 nLBData = nNumberingType; | |||
502 | m_xFmtLB->set_active_id(OUString::number(nLBData)); | |||
503 | } | |||
504 | else | |||
505 | m_xFmtLB->set_active(-1); | |||
506 | ||||
507 | if (bBullRelSize) | |||
508 | { | |||
509 | if (bSameBulRelSize) | |||
510 | m_xBulRelSizeMF->set_value(aNumFmtArr[nLvl]->GetBulletRelSize(), FieldUnit::PERCENT); | |||
511 | else | |||
512 | m_xBulRelSizeMF->set_text(""); | |||
513 | } | |||
514 | if (bBullColor) | |||
515 | { | |||
516 | if (bSameBulColor) | |||
517 | m_xBulColLB->SelectEntry(aNumFmtArr[nLvl]->GetBulletColor()); | |||
518 | else | |||
519 | m_xBulColLB->SetNoSelection(); | |||
520 | } | |||
521 | switch (nBullet) | |||
522 | { | |||
523 | case SHOW_NUMBERING0: | |||
524 | if (bSameStart) | |||
525 | { | |||
526 | m_xStartED->set_value(aNumFmtArr[nLvl]->GetStart()); | |||
527 | } | |||
528 | else | |||
529 | m_xStartED->set_text(""); | |||
530 | break; | |||
531 | case SHOW_BULLET1: | |||
532 | break; | |||
533 | case SHOW_BITMAP2: | |||
534 | break; | |||
535 | } | |||
536 | ||||
537 | switch (eFirstAdjust) | |||
538 | { | |||
539 | case SvxAdjust::Left: | |||
540 | m_xLeftTB->set_active(true); | |||
541 | m_xCenterTB->set_active(false); | |||
542 | m_xRightTB->set_active(false); | |||
543 | break; | |||
544 | case SvxAdjust::Center: | |||
545 | m_xLeftTB->set_active(false); | |||
546 | m_xCenterTB->set_active(true); | |||
547 | m_xRightTB->set_active(false); | |||
548 | break; | |||
549 | case SvxAdjust::Right: | |||
550 | m_xLeftTB->set_active(false); | |||
551 | m_xCenterTB->set_active(false); | |||
552 | m_xRightTB->set_active(true); | |||
553 | break; | |||
554 | default: | |||
555 | break; | |||
556 | } | |||
557 | ||||
558 | if (bSamePrefix) | |||
559 | m_xPrefixED->set_text(aNumFmtArr[nLvl]->GetPrefix()); | |||
560 | else | |||
561 | m_xPrefixED->set_text(""); | |||
562 | if (bSameSuffix) | |||
563 | m_xSuffixED->set_text(aNumFmtArr[nLvl]->GetSuffix()); | |||
564 | else | |||
565 | m_xSuffixED->set_text(""); | |||
566 | ||||
567 | if (bSameDistBorderNum) | |||
568 | { | |||
569 | long nDistBorderNum; | |||
570 | if (bRelative) | |||
571 | { | |||
572 | nDistBorderNum = static_cast<long>(aNumFmtArr[nLvl]->GetAbsLSpace()) | |||
573 | + aNumFmtArr[nLvl]->GetFirstLineOffset(); | |||
574 | if (nLvl) | |||
575 | nDistBorderNum -= static_cast<long>(aNumFmtArr[nLvl - 1]->GetAbsLSpace()) | |||
576 | + aNumFmtArr[nLvl - 1]->GetFirstLineOffset(); | |||
577 | } | |||
578 | else | |||
579 | { | |||
580 | nDistBorderNum = static_cast<long>(aNumFmtArr[nLvl]->GetAbsLSpace()) | |||
581 | + aNumFmtArr[nLvl]->GetFirstLineOffset(); | |||
582 | } | |||
583 | SetMetricValue(*m_xDistBorderMF, nDistBorderNum, eCoreUnit); | |||
584 | } | |||
585 | else | |||
586 | bSetDistEmpty = true; | |||
587 | ||||
588 | if (bSetDistEmpty) | |||
589 | m_xDistBorderMF->set_text(""); | |||
590 | ||||
591 | if (bSameIndent) | |||
592 | SetMetricValue(*m_xIndentMF, -aNumFmtArr[nLvl]->GetFirstLineOffset(), eCoreUnit); | |||
593 | else | |||
594 | m_xIndentMF->set_text(""); | |||
595 | ||||
596 | m_xSelectionRB->set_active(true); | |||
597 | ||||
598 | m_aPreviewWIN.SetLevel(nActNumLvl); | |||
599 | m_aPreviewWIN.Invalidate(); | |||
600 | bInInitControl = false; | |||
601 | } | |||
602 | ||||
603 | // 0 - Number; 1 - Bullet; 2 - Bitmap | |||
604 | void SvxBulletAndPositionDlg::SwitchNumberType(sal_uInt8 nType) | |||
605 | { | |||
606 | if (nBullet == nType) | |||
607 | return; | |||
608 | nBullet = nType; | |||
609 | bool bBullet = (nType == SHOW_BULLET1); | |||
610 | bool bBitmap = (nType == SHOW_BITMAP2); | |||
611 | bool bEnableBitmap = (nType == SHOW_BITMAP2); | |||
612 | bool bNumeric = !(bBitmap || bBullet); | |||
613 | m_xPrefixFT->set_visible(bNumeric); | |||
614 | m_xPrefixED->set_visible(bNumeric); | |||
615 | m_xSuffixFT->set_visible(bNumeric); | |||
616 | m_xSuffixED->set_visible(bNumeric); | |||
617 | m_xBeforeAfter->set_visible(bNumeric); | |||
618 | ||||
619 | m_xStartFT->set_visible(!(bBullet || bBitmap)); | |||
620 | m_xStartED->set_visible(!(bBullet || bBitmap)); | |||
621 | ||||
622 | m_xBulletFT->set_visible(bBullet); | |||
623 | m_xBulletPB->set_visible(bBullet); | |||
624 | bool bBullColor = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_COLOR); | |||
625 | m_xBulColorFT->set_visible(!bBitmap && bBullColor); | |||
626 | m_xBulColLB->set_visible(!bBitmap && bBullColor); | |||
627 | bool bBullResSize = pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE); | |||
628 | m_xBulRelSizeFT->set_visible(!bBitmap && bBullResSize); | |||
629 | m_xBulRelSizeMF->set_visible(!bBitmap && bBullResSize); | |||
630 | ||||
631 | m_xBitmapMB->set_visible(bBitmap); | |||
632 | ||||
633 | m_xWidthFT->set_visible(bBitmap); | |||
634 | m_xWidthMF->set_visible(bBitmap); | |||
635 | m_xHeightFT->set_visible(bBitmap); | |||
636 | m_xHeightMF->set_visible(bBitmap); | |||
637 | m_xRatioCB->set_visible(bBitmap); | |||
638 | ||||
639 | m_xWidthFT->set_sensitive(bEnableBitmap); | |||
640 | m_xWidthMF->set_sensitive(bEnableBitmap); | |||
641 | m_xHeightFT->set_sensitive(bEnableBitmap); | |||
642 | m_xHeightMF->set_sensitive(bEnableBitmap); | |||
643 | m_xRatioCB->set_sensitive(bEnableBitmap); | |||
644 | } | |||
645 | ||||
646 | void SvxBulletAndPositionDlg::CheckForStartValue_Impl(sal_uInt16 nNumberingType) | |||
647 | { | |||
648 | bool bIsNull = m_xStartED->get_value() == 0; | |||
649 | bool bNoZeroAllowed = nNumberingType < SVX_NUM_ARABIC | |||
650 | || SVX_NUM_CHARS_UPPER_LETTER_N == nNumberingType | |||
651 | || SVX_NUM_CHARS_LOWER_LETTER_N == nNumberingType; | |||
652 | m_xStartED->set_min(bNoZeroAllowed ? 1 : 0); | |||
653 | if (bIsNull && bNoZeroAllowed) | |||
654 | EditModifyHdl_Impl(*m_xStartED); | |||
655 | } | |||
656 | ||||
657 | IMPL_LINK(SvxBulletAndPositionDlg, LevelHdl_Impl, weld::TreeView&, rBox, void)void SvxBulletAndPositionDlg::LinkStubLevelHdl_Impl(void * instance , weld::TreeView& data) { return static_cast<SvxBulletAndPositionDlg *>(instance)->LevelHdl_Impl(data); } void SvxBulletAndPositionDlg ::LevelHdl_Impl(weld::TreeView& rBox) | |||
658 | { | |||
659 | sal_uInt16 nSaveNumLvl = nActNumLvl; | |||
660 | nActNumLvl = 0; | |||
661 | auto aSelectedRows = rBox.get_selected_rows(); | |||
662 | if (std::find(aSelectedRows.begin(), aSelectedRows.end(), pActNum->GetLevelCount()) | |||
663 | != aSelectedRows.end() | |||
664 | && (aSelectedRows.size() == 1 || nSaveNumLvl != 0xffff)) | |||
665 | { | |||
666 | nActNumLvl = 0xFFFF; | |||
667 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
668 | rBox.unselect(i); | |||
669 | } | |||
670 | else if (!aSelectedRows.empty()) | |||
671 | { | |||
672 | sal_uInt16 nMask = 1; | |||
673 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
674 | { | |||
675 | if (std::find(aSelectedRows.begin(), aSelectedRows.end(), i) != aSelectedRows.end()) | |||
676 | nActNumLvl |= nMask; | |||
677 | nMask <<= 1; | |||
678 | } | |||
679 | rBox.unselect(pActNum->GetLevelCount()); | |||
680 | } | |||
681 | else | |||
682 | nActNumLvl = nSaveNumLvl; | |||
683 | ||||
684 | InitControls(); | |||
685 | } | |||
686 | ||||
687 | IMPL_LINK_NOARG(SvxBulletAndPositionDlg, PreviewInvalidateHdl_Impl, Timer*, void)void SvxBulletAndPositionDlg::LinkStubPreviewInvalidateHdl_Impl (void * instance, Timer* data) { return static_cast<SvxBulletAndPositionDlg *>(instance)->PreviewInvalidateHdl_Impl(data); } void SvxBulletAndPositionDlg ::PreviewInvalidateHdl_Impl(__attribute__ ((unused)) Timer*) | |||
688 | { | |||
689 | m_aPreviewWIN.Invalidate(); | |||
690 | } | |||
691 | ||||
692 | IMPL_LINK(SvxBulletAndPositionDlg, NumberTypeSelectHdl_Impl, weld::ComboBox&, rBox, void)void SvxBulletAndPositionDlg::LinkStubNumberTypeSelectHdl_Impl (void * instance, weld::ComboBox& data) { return static_cast <SvxBulletAndPositionDlg *>(instance)->NumberTypeSelectHdl_Impl (data); } void SvxBulletAndPositionDlg::NumberTypeSelectHdl_Impl (weld::ComboBox& rBox) | |||
693 | { | |||
694 | OUString sSelectStyle; | |||
695 | bool bBmp = false; | |||
696 | sal_uInt16 nMask = 1; | |||
697 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
698 | { | |||
699 | if (nActNumLvl & nMask) | |||
700 | { | |||
701 | SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); | |||
702 | // PAGEDESC does not exist | |||
703 | SvxNumType nNumType = static_cast<SvxNumType>(rBox.get_active_id().toUInt32()); | |||
704 | aNumFmt.SetNumberingType(nNumType); | |||
705 | sal_uInt16 nNumberingType = aNumFmt.GetNumberingType(); | |||
706 | if (SVX_NUM_BITMAP == (nNumberingType & (~LINK_TOKEN0x80))) | |||
707 | { | |||
708 | bBmp |= nullptr != aNumFmt.GetBrush(); | |||
709 | aNumFmt.SetIncludeUpperLevels(0); | |||
710 | aNumFmt.SetSuffix(""); | |||
711 | aNumFmt.SetPrefix(""); | |||
712 | if (!bBmp) | |||
713 | aNumFmt.SetGraphic(""); | |||
714 | pActNum->SetLevel(i, aNumFmt); | |||
715 | SwitchNumberType(SHOW_BITMAP2); | |||
716 | } | |||
717 | else if (SVX_NUM_CHAR_SPECIAL == nNumberingType) | |||
718 | { | |||
719 | aNumFmt.SetIncludeUpperLevels(0); | |||
720 | aNumFmt.SetSuffix(""); | |||
721 | aNumFmt.SetPrefix(""); | |||
722 | if (!aNumFmt.GetBulletFont()) | |||
723 | aNumFmt.SetBulletFont(&aActBulletFont); | |||
724 | if (!aNumFmt.GetBulletChar()) | |||
725 | aNumFmt.SetBulletChar(SVX_DEF_BULLET(0xF000 + 149)); | |||
726 | pActNum->SetLevel(i, aNumFmt); | |||
727 | SwitchNumberType(SHOW_BULLET1); | |||
728 | // allocation of the drawing pattern is automatic | |||
729 | sSelectStyle = m_sBulletCharFormatName; | |||
730 | } | |||
731 | else | |||
732 | { | |||
733 | aNumFmt.SetPrefix(m_xPrefixED->get_text()); | |||
734 | aNumFmt.SetSuffix(m_xSuffixED->get_text()); | |||
735 | SwitchNumberType(SHOW_NUMBERING0); | |||
736 | pActNum->SetLevel(i, aNumFmt); | |||
737 | CheckForStartValue_Impl(nNumberingType); | |||
738 | ||||
739 | // allocation of the drawing pattern is automatic | |||
740 | sSelectStyle = m_sNumCharFmtName; | |||
741 | } | |||
742 | } | |||
743 | nMask <<= 1; | |||
744 | } | |||
745 | ||||
746 | SetModified(); | |||
747 | } | |||
748 | ||||
749 | IMPL_LINK(SvxBulletAndPositionDlg, BulColorHdl_Impl, ColorListBox&, rColorBox, void)void SvxBulletAndPositionDlg::LinkStubBulColorHdl_Impl(void * instance, ColorListBox& data) { return static_cast<SvxBulletAndPositionDlg *>(instance)->BulColorHdl_Impl(data); } void SvxBulletAndPositionDlg ::BulColorHdl_Impl(ColorListBox& rColorBox) | |||
750 | { | |||
751 | Color nSetColor = rColorBox.GetSelectEntryColor(); | |||
752 | ||||
753 | sal_uInt16 nMask = 1; | |||
754 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
755 | { | |||
756 | if (nActNumLvl & nMask) | |||
757 | { | |||
758 | SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); | |||
759 | aNumFmt.SetBulletColor(nSetColor); | |||
760 | pActNum->SetLevel(i, aNumFmt); | |||
761 | } | |||
762 | nMask <<= 1; | |||
763 | } | |||
764 | SetModified(); | |||
765 | } | |||
766 | ||||
767 | IMPL_LINK(SvxBulletAndPositionDlg, BulRelSizeHdl_Impl, weld::MetricSpinButton&, rField, void)void SvxBulletAndPositionDlg::LinkStubBulRelSizeHdl_Impl(void * instance, weld::MetricSpinButton& data) { return static_cast <SvxBulletAndPositionDlg *>(instance)->BulRelSizeHdl_Impl (data); } void SvxBulletAndPositionDlg::BulRelSizeHdl_Impl(weld ::MetricSpinButton& rField) | |||
768 | { | |||
769 | sal_uInt16 nRelSize = rField.get_value(FieldUnit::PERCENT); | |||
770 | ||||
771 | sal_uInt16 nMask = 1; | |||
772 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
773 | { | |||
774 | if (nActNumLvl & nMask) | |||
775 | { | |||
776 | SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); | |||
777 | aNumFmt.SetBulletRelSize(nRelSize); | |||
778 | pActNum->SetLevel(i, aNumFmt); | |||
779 | } | |||
780 | nMask <<= 1; | |||
781 | } | |||
782 | SetModified(); | |||
783 | } | |||
784 | ||||
785 | IMPL_LINK(SvxBulletAndPositionDlg, GraphicHdl_Impl, const OString&, rIdent, void)void SvxBulletAndPositionDlg::LinkStubGraphicHdl_Impl(void * instance , const OString& data) { return static_cast<SvxBulletAndPositionDlg *>(instance)->GraphicHdl_Impl(data); } void SvxBulletAndPositionDlg ::GraphicHdl_Impl(const OString& rIdent) | |||
786 | { | |||
787 | OUString aGrfName; | |||
788 | Size aSize; | |||
789 | bool bSucc(false); | |||
790 | SvxOpenGraphicDialog aGrfDlg(SdResId(RID_SVXSTR_EDIT_GRAPHICreinterpret_cast<char const *>("RID_SVXSTR_EDIT_GRAPHIC" "\004" u8"Link")), p_Window); | |||
791 | ||||
792 | OString sNumber; | |||
793 | if (rIdent.startsWith("gallery", &sNumber)) | |||
794 | { | |||
795 | auto idx = sNumber.toUInt32(); | |||
796 | if (idx < aGrfNames.size()) | |||
797 | { | |||
798 | aGrfName = aGrfNames[idx]; | |||
799 | Graphic aGraphic; | |||
800 | if (GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS3, idx, &aGraphic)) | |||
801 | { | |||
802 | aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic); | |||
803 | bSucc = true; | |||
804 | } | |||
805 | } | |||
806 | } | |||
807 | else if (rIdent == "fromfile") | |||
808 | { | |||
809 | aGrfDlg.EnableLink(false); | |||
810 | aGrfDlg.AsLink(false); | |||
811 | if (!aGrfDlg.Execute()) | |||
812 | { | |||
813 | // memorize selected filter | |||
814 | aGrfName = aGrfDlg.GetPath(); | |||
815 | ||||
816 | Graphic aGraphic; | |||
817 | if (!aGrfDlg.GetGraphic(aGraphic)) | |||
818 | { | |||
819 | aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic); | |||
820 | bSucc = true; | |||
821 | } | |||
822 | } | |||
823 | } | |||
824 | if (!bSucc) | |||
825 | return; | |||
826 | ||||
827 | aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit)); | |||
828 | ||||
829 | sal_uInt16 nMask = 1; | |||
830 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
831 | { | |||
832 | if (nActNumLvl & nMask) | |||
833 | { | |||
834 | SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); | |||
835 | aNumFmt.SetCharFormatName(m_sNumCharFmtName); | |||
836 | aNumFmt.SetGraphic(aGrfName); | |||
837 | ||||
838 | // set size for a later comparison | |||
839 | const SvxBrushItem* pBrushItem = aNumFmt.GetBrush(); | |||
840 | // initiate asynchronous loading | |||
841 | sal_Int16 eOrient = aNumFmt.GetVertOrient(); | |||
842 | aNumFmt.SetGraphicBrush(pBrushItem, &aSize, &eOrient); | |||
843 | aInitSize[i] = aNumFmt.GetGraphicSize(); | |||
844 | ||||
845 | pActNum->SetLevel(i, aNumFmt); | |||
846 | } | |||
847 | nMask <<= 1; | |||
848 | } | |||
849 | m_xRatioCB->set_sensitive(true); | |||
850 | m_xWidthFT->set_sensitive(true); | |||
851 | m_xHeightFT->set_sensitive(true); | |||
852 | m_xWidthMF->set_sensitive(true); | |||
853 | m_xHeightMF->set_sensitive(true); | |||
854 | SetMetricValue(*m_xWidthMF, aSize.Width(), eCoreUnit); | |||
855 | SetMetricValue(*m_xHeightMF, aSize.Height(), eCoreUnit); | |||
856 | ||||
857 | SetModified(); | |||
858 | //needed due to asynchronous loading of graphics in the SvxBrushItem | |||
859 | aInvalidateTimer.Start(); | |||
860 | } | |||
861 | ||||
862 | IMPL_LINK_NOARG(SvxBulletAndPositionDlg, PopupActivateHdl_Impl, weld::ToggleButton&, void)void SvxBulletAndPositionDlg::LinkStubPopupActivateHdl_Impl(void * instance, weld::ToggleButton& data) { return static_cast <SvxBulletAndPositionDlg *>(instance)->PopupActivateHdl_Impl (data); } void SvxBulletAndPositionDlg::PopupActivateHdl_Impl (__attribute__ ((unused)) weld::ToggleButton&) | |||
| ||||
863 | { | |||
864 | if (m_xGalleryMenu) | |||
865 | return; | |||
866 | ||||
867 | m_xGalleryMenu = m_xBuilder->weld_menu("gallerysubmenu"); | |||
868 | weld::WaitObject aWait(p_Window); | |||
869 | ||||
870 | if (!GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS3, aGrfNames)) | |||
871 | return; | |||
872 | ||||
873 | GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS3); | |||
874 | ||||
875 | Graphic aGraphic; | |||
876 | OUString sGrfName; | |||
877 | ScopedVclPtrInstance<VirtualDevice> pVD; | |||
878 | size_t i = 0; | |||
879 | for (const auto& grfName : aGrfNames) | |||
880 | { | |||
881 | sGrfName = grfName; | |||
882 | OUString sItemId = "gallery" + OUString::number(i); | |||
883 | INetURLObject aObj(sGrfName); | |||
884 | if (aObj.GetProtocol() == INetProtocol::File) | |||
885 | sGrfName = aObj.PathToFileName(); | |||
886 | if (GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS3, i, &aGraphic)) | |||
887 | { | |||
888 | BitmapEx aBitmap(aGraphic.GetBitmapEx()); | |||
889 | Size aSize(aBitmap.GetSizePixel()); | |||
890 | if (aSize.Width() > MAX_BMP_WIDTH16 || aSize.Height() > MAX_BMP_HEIGHT16) | |||
891 | { | |||
892 | bool bWidth = aSize.Width() > aSize.Height(); | |||
893 | double nScale = bWidth | |||
894 | ? double(MAX_BMP_WIDTH16) / static_cast<double>(aSize.Width()) | |||
895 | : double(MAX_BMP_HEIGHT16) / static_cast<double>(aSize.Height()); | |||
896 | aBitmap.Scale(nScale, nScale); | |||
897 | } | |||
898 | pVD->SetOutputSizePixel(aBitmap.GetSizePixel(), false); | |||
899 | pVD->DrawBitmapEx(Point(), aBitmap); | |||
900 | ||||
901 | // We want to show only icon names not full path. | |||
902 | aObj.removeExtension(); | |||
903 | OUString sIconName = aObj.GetLastName(INetURLObject::DecodeMechanism::WithCharset); | |||
904 | ||||
905 | m_xGalleryMenu->append(sItemId, sIconName, *pVD); | |||
906 | } | |||
907 | else | |||
908 | { | |||
909 | m_xGalleryMenu->append(sItemId, sGrfName); | |||
910 | } | |||
911 | ++i; | |||
912 | } | |||
913 | GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS3); | |||
914 | } | |||
915 | ||||
916 | IMPL_LINK_NOARG(SvxBulletAndPositionDlg, BulletHdl_Impl, weld::Button&, void)void SvxBulletAndPositionDlg::LinkStubBulletHdl_Impl(void * instance , weld::Button& data) { return static_cast<SvxBulletAndPositionDlg *>(instance)->BulletHdl_Impl(data); } void SvxBulletAndPositionDlg ::BulletHdl_Impl(__attribute__ ((unused)) weld::Button&) | |||
917 | { | |||
918 | SvxCharacterMap aMap(p_Window, nullptr, nullptr); | |||
919 | ||||
920 | sal_uInt16 nMask = 1; | |||
921 | const vcl::Font* pFmtFont = nullptr; | |||
922 | bool bSameBullet = true; | |||
923 | sal_UCS4 cBullet = 0; | |||
924 | bool bFirst = true; | |||
925 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
926 | { | |||
927 | if (nActNumLvl & nMask) | |||
928 | { | |||
929 | const SvxNumberFormat& rCurFmt = pActNum->GetLevel(i); | |||
930 | if (bFirst) | |||
931 | { | |||
932 | cBullet = rCurFmt.GetBulletChar(); | |||
933 | } | |||
934 | else if (rCurFmt.GetBulletChar() != cBullet) | |||
935 | { | |||
936 | bSameBullet = false; | |||
937 | break; | |||
938 | } | |||
939 | if (!pFmtFont) | |||
940 | pFmtFont = rCurFmt.GetBulletFont(); | |||
941 | bFirst = false; | |||
942 | } | |||
943 | nMask <<= 1; | |||
944 | } | |||
945 | ||||
946 | if (pFmtFont) | |||
947 | aMap.SetCharFont(*pFmtFont); | |||
948 | else | |||
949 | aMap.SetCharFont(aActBulletFont); | |||
950 | if (bSameBullet) | |||
951 | aMap.SetChar(cBullet); | |||
952 | if (aMap.run() != RET_OK) | |||
953 | return; | |||
954 | ||||
955 | // change Font Numrules | |||
956 | aActBulletFont = aMap.GetCharFont(); | |||
957 | ||||
958 | sal_uInt16 _nMask = 1; | |||
959 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
960 | { | |||
961 | if (nActNumLvl & _nMask) | |||
962 | { | |||
963 | SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); | |||
964 | aNumFmt.SetBulletFont(&aActBulletFont); | |||
965 | aNumFmt.SetBulletChar(aMap.GetChar()); | |||
966 | pActNum->SetLevel(i, aNumFmt); | |||
967 | } | |||
968 | _nMask <<= 1; | |||
969 | } | |||
970 | ||||
971 | SetModified(); | |||
972 | } | |||
973 | ||||
974 | IMPL_LINK(SvxBulletAndPositionDlg, SizeHdl_Impl, weld::MetricSpinButton&, rField, void)void SvxBulletAndPositionDlg::LinkStubSizeHdl_Impl(void * instance , weld::MetricSpinButton& data) { return static_cast<SvxBulletAndPositionDlg *>(instance)->SizeHdl_Impl(data); } void SvxBulletAndPositionDlg ::SizeHdl_Impl(weld::MetricSpinButton& rField) | |||
975 | { | |||
976 | bool bWidth = &rField == m_xWidthMF.get(); | |||
977 | bLastWidthModified = bWidth; | |||
978 | bool bRatio = m_xRatioCB->get_active(); | |||
979 | long nWidthVal | |||
980 | = static_cast<long>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::MM_100TH))); | |||
981 | long nHeightVal | |||
982 | = static_cast<long>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FieldUnit::MM_100TH))); | |||
983 | nWidthVal = OutputDevice::LogicToLogic(nWidthVal, MapUnit::Map100thMM, eCoreUnit); | |||
984 | nHeightVal = OutputDevice::LogicToLogic(nHeightVal, MapUnit::Map100thMM, eCoreUnit); | |||
985 | double fSizeRatio; | |||
986 | ||||
987 | bool bRepaint = false; | |||
988 | sal_uInt16 nMask = 1; | |||
989 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
990 | { | |||
991 | if (nActNumLvl & nMask) | |||
992 | { | |||
993 | SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); | |||
994 | if (SVX_NUM_BITMAP == (aNumFmt.GetNumberingType() & (~LINK_TOKEN0x80))) | |||
995 | { | |||
996 | Size aSize(aNumFmt.GetGraphicSize()); | |||
997 | Size aSaveSize(aSize); | |||
998 | ||||
999 | if (aInitSize[i].Height()) | |||
1000 | fSizeRatio = static_cast<double>(aInitSize[i].Width()) | |||
1001 | / static_cast<double>(aInitSize[i].Height()); | |||
1002 | else | |||
1003 | fSizeRatio = double(1); | |||
1004 | ||||
1005 | if (bWidth) | |||
1006 | { | |||
1007 | long nDelta = nWidthVal - aInitSize[i].Width(); | |||
1008 | aSize.setWidth(nWidthVal); | |||
1009 | if (bRatio) | |||
1010 | { | |||
1011 | aSize.setHeight( | |||
1012 | aInitSize[i].Height() | |||
1013 | + static_cast<long>(static_cast<double>(nDelta) / fSizeRatio)); | |||
1014 | m_xHeightMF->set_value(m_xHeightMF->normalize(OutputDevice::LogicToLogic( | |||
1015 | aSize.Height(), eCoreUnit, MapUnit::Map100thMM)), | |||
1016 | FieldUnit::MM_100TH); | |||
1017 | } | |||
1018 | } | |||
1019 | else | |||
1020 | { | |||
1021 | long nDelta = nHeightVal - aInitSize[i].Height(); | |||
1022 | aSize.setHeight(nHeightVal); | |||
1023 | if (bRatio) | |||
1024 | { | |||
1025 | aSize.setWidth( | |||
1026 | aInitSize[i].Width() | |||
1027 | + static_cast<long>(static_cast<double>(nDelta) * fSizeRatio)); | |||
1028 | m_xWidthMF->set_value(m_xWidthMF->normalize(OutputDevice::LogicToLogic( | |||
1029 | aSize.Width(), eCoreUnit, MapUnit::Map100thMM)), | |||
1030 | FieldUnit::MM_100TH); | |||
1031 | } | |||
1032 | } | |||
1033 | const SvxBrushItem* pBrushItem = aNumFmt.GetBrush(); | |||
1034 | sal_Int16 eOrient = aNumFmt.GetVertOrient(); | |||
1035 | if (aSize != aSaveSize) | |||
1036 | bRepaint = true; | |||
1037 | aNumFmt.SetGraphicBrush(pBrushItem, &aSize, &eOrient); | |||
1038 | pActNum->SetLevel(i, aNumFmt); | |||
1039 | } | |||
1040 | } | |||
1041 | nMask <<= 1; | |||
1042 | } | |||
1043 | SetModified(bRepaint); | |||
1044 | } | |||
1045 | ||||
1046 | IMPL_LINK(SvxBulletAndPositionDlg, RatioHdl_Impl, weld::ToggleButton&, rBox, void)void SvxBulletAndPositionDlg::LinkStubRatioHdl_Impl(void * instance , weld::ToggleButton& data) { return static_cast<SvxBulletAndPositionDlg *>(instance)->RatioHdl_Impl(data); } void SvxBulletAndPositionDlg ::RatioHdl_Impl(weld::ToggleButton& rBox) | |||
1047 | { | |||
1048 | if (rBox.get_active()) | |||
1049 | { | |||
1050 | if (bLastWidthModified) | |||
1051 | SizeHdl_Impl(*m_xWidthMF); | |||
1052 | else | |||
1053 | SizeHdl_Impl(*m_xHeightMF); | |||
1054 | } | |||
1055 | } | |||
1056 | ||||
1057 | IMPL_LINK(SvxBulletAndPositionDlg, SelectLeftAlignmentHdl_Impl, weld::ToggleButton&, rButton, void)void SvxBulletAndPositionDlg::LinkStubSelectLeftAlignmentHdl_Impl (void * instance, weld::ToggleButton& data) { return static_cast <SvxBulletAndPositionDlg *>(instance)->SelectLeftAlignmentHdl_Impl (data); } void SvxBulletAndPositionDlg::SelectLeftAlignmentHdl_Impl (weld::ToggleButton& rButton) | |||
1058 | { | |||
1059 | if (rButton.get_active()) | |||
1060 | { | |||
1061 | SetAlignmentHdl_Impl(SvxAdjust::Left); | |||
1062 | ||||
1063 | m_xCenterTB->set_active(false); | |||
1064 | m_xRightTB->set_active(false); | |||
1065 | ||||
1066 | SetModified(); | |||
1067 | } | |||
1068 | } | |||
1069 | ||||
1070 | IMPL_LINK(SvxBulletAndPositionDlg, SelectCenterAlignmentHdl_Impl, weld::ToggleButton&, rButton,void SvxBulletAndPositionDlg::LinkStubSelectCenterAlignmentHdl_Impl (void * instance, weld::ToggleButton& data) { return static_cast <SvxBulletAndPositionDlg *>(instance)->SelectCenterAlignmentHdl_Impl (data); } void SvxBulletAndPositionDlg::SelectCenterAlignmentHdl_Impl (weld::ToggleButton& rButton) | |||
1071 | void)void SvxBulletAndPositionDlg::LinkStubSelectCenterAlignmentHdl_Impl (void * instance, weld::ToggleButton& data) { return static_cast <SvxBulletAndPositionDlg *>(instance)->SelectCenterAlignmentHdl_Impl (data); } void SvxBulletAndPositionDlg::SelectCenterAlignmentHdl_Impl (weld::ToggleButton& rButton) | |||
1072 | { | |||
1073 | if (rButton.get_active()) | |||
1074 | { | |||
1075 | SetAlignmentHdl_Impl(SvxAdjust::Center); | |||
1076 | ||||
1077 | m_xLeftTB->set_active(false); | |||
1078 | m_xRightTB->set_active(false); | |||
1079 | ||||
1080 | SetModified(); | |||
1081 | } | |||
1082 | } | |||
1083 | ||||
1084 | IMPL_LINK(SvxBulletAndPositionDlg, SelectRightAlignmentHdl_Impl, weld::ToggleButton&, rButton, void)void SvxBulletAndPositionDlg::LinkStubSelectRightAlignmentHdl_Impl (void * instance, weld::ToggleButton& data) { return static_cast <SvxBulletAndPositionDlg *>(instance)->SelectRightAlignmentHdl_Impl (data); } void SvxBulletAndPositionDlg::SelectRightAlignmentHdl_Impl (weld::ToggleButton& rButton) | |||
1085 | { | |||
1086 | if (rButton.get_active()) | |||
1087 | { | |||
1088 | SetAlignmentHdl_Impl(SvxAdjust::Right); | |||
1089 | ||||
1090 | m_xLeftTB->set_active(false); | |||
1091 | m_xCenterTB->set_active(false); | |||
1092 | ||||
1093 | SetModified(); | |||
1094 | } | |||
1095 | } | |||
1096 | ||||
1097 | void SvxBulletAndPositionDlg::SetAlignmentHdl_Impl(SvxAdjust eAdjust) | |||
1098 | { | |||
1099 | sal_uInt16 nMask = 1; | |||
1100 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
1101 | { | |||
1102 | if (nActNumLvl & nMask) | |||
1103 | { | |||
1104 | SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); | |||
1105 | aNumFmt.SetNumAdjust(eAdjust); | |||
1106 | pActNum->SetLevel(i, aNumFmt); | |||
1107 | } | |||
1108 | nMask <<= 1; | |||
1109 | } | |||
1110 | } | |||
1111 | ||||
1112 | IMPL_LINK(SvxBulletAndPositionDlg, ApplyToMasterHdl_Impl, weld::ToggleButton&, rButton, void)void SvxBulletAndPositionDlg::LinkStubApplyToMasterHdl_Impl(void * instance, weld::ToggleButton& data) { return static_cast <SvxBulletAndPositionDlg *>(instance)->ApplyToMasterHdl_Impl (data); } void SvxBulletAndPositionDlg::ApplyToMasterHdl_Impl (weld::ToggleButton& rButton) | |||
1113 | { | |||
1114 | bApplyToMaster = rButton.get_active(); | |||
1115 | } | |||
1116 | ||||
1117 | IMPL_LINK_NOARG(SvxBulletAndPositionDlg, ResetHdl_Impl, weld::Button&, void)void SvxBulletAndPositionDlg::LinkStubResetHdl_Impl(void * instance , weld::Button& data) { return static_cast<SvxBulletAndPositionDlg *>(instance)->ResetHdl_Impl(data); } void SvxBulletAndPositionDlg ::ResetHdl_Impl(__attribute__ ((unused)) weld::Button&) | |||
1118 | { | |||
1119 | Reset(&rFirstStateSet); | |||
1120 | } | |||
1121 | ||||
1122 | IMPL_LINK(SvxBulletAndPositionDlg, EditModifyHdl_Impl, weld::Entry&, rEdit, void)void SvxBulletAndPositionDlg::LinkStubEditModifyHdl_Impl(void * instance, weld::Entry& data) { return static_cast<SvxBulletAndPositionDlg *>(instance)->EditModifyHdl_Impl(data); } void SvxBulletAndPositionDlg ::EditModifyHdl_Impl(weld::Entry& rEdit) | |||
1123 | { | |||
1124 | EditModifyHdl_Impl(&rEdit); | |||
1125 | } | |||
1126 | ||||
1127 | IMPL_LINK(SvxBulletAndPositionDlg, DistanceHdl_Impl, weld::MetricSpinButton&, rFld, void)void SvxBulletAndPositionDlg::LinkStubDistanceHdl_Impl(void * instance, weld::MetricSpinButton& data) { return static_cast <SvxBulletAndPositionDlg *>(instance)->DistanceHdl_Impl (data); } void SvxBulletAndPositionDlg::DistanceHdl_Impl(weld ::MetricSpinButton& rFld) | |||
1128 | { | |||
1129 | if (bInInitControl) | |||
1130 | return; | |||
1131 | long nValue = GetCoreValue(rFld, eCoreUnit); | |||
1132 | sal_uInt16 nMask = 1; | |||
1133 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
1134 | { | |||
1135 | if (nActNumLvl & nMask) | |||
1136 | { | |||
1137 | SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); | |||
1138 | if (&rFld == m_xDistBorderMF.get()) | |||
1139 | { | |||
1140 | if (m_xRelativeCB->get_active()) | |||
1141 | { | |||
1142 | if (0 == i) | |||
1143 | { | |||
1144 | auto const nTmp = aNumFmt.GetFirstLineOffset(); | |||
1145 | aNumFmt.SetAbsLSpace(nValue - nTmp); | |||
1146 | } | |||
1147 | else | |||
1148 | { | |||
1149 | long nTmp = pActNum->GetLevel(i - 1).GetAbsLSpace() | |||
1150 | + pActNum->GetLevel(i - 1).GetFirstLineOffset() | |||
1151 | - pActNum->GetLevel(i).GetFirstLineOffset(); | |||
1152 | ||||
1153 | aNumFmt.SetAbsLSpace(nValue + nTmp); | |||
1154 | } | |||
1155 | } | |||
1156 | else | |||
1157 | { | |||
1158 | aNumFmt.SetAbsLSpace(nValue - aNumFmt.GetFirstLineOffset()); | |||
1159 | } | |||
1160 | } | |||
1161 | else if (&rFld == m_xIndentMF.get()) | |||
1162 | { | |||
1163 | // together with the FirstLineOffset the AbsLSpace must be changed, too | |||
1164 | long nDiff = nValue + aNumFmt.GetFirstLineOffset(); | |||
1165 | auto const nAbsLSpace = aNumFmt.GetAbsLSpace(); | |||
1166 | aNumFmt.SetAbsLSpace(nAbsLSpace + nDiff); | |||
1167 | aNumFmt.SetFirstLineOffset(-nValue); | |||
1168 | } | |||
1169 | ||||
1170 | pActNum->SetLevel(i, aNumFmt); | |||
1171 | } | |||
1172 | nMask <<= 1; | |||
1173 | } | |||
1174 | ||||
1175 | SetModified(); | |||
1176 | if (!m_xDistBorderMF->get_sensitive()) | |||
1177 | { | |||
1178 | m_xDistBorderMF->set_text(""); | |||
1179 | } | |||
1180 | ||||
1181 | sal_Int32 aLastLevelLSpace | |||
1182 | = pActNum->GetLevel(pActNum->GetLevelCount() - 1).GetAbsLSpace() / 40; | |||
1183 | m_aPreviewWIN.set_size_request(aLastLevelLSpace, 300); | |||
1184 | } | |||
1185 | ||||
1186 | IMPL_LINK(SvxBulletAndPositionDlg, RelativeHdl_Impl, weld::ToggleButton&, rBox, void)void SvxBulletAndPositionDlg::LinkStubRelativeHdl_Impl(void * instance, weld::ToggleButton& data) { return static_cast <SvxBulletAndPositionDlg *>(instance)->RelativeHdl_Impl (data); } void SvxBulletAndPositionDlg::RelativeHdl_Impl(weld ::ToggleButton& rBox) | |||
1187 | { | |||
1188 | bool bOn = rBox.get_active(); | |||
1189 | bool bSingleSelection = m_xLevelLB->count_selected_rows() == 1 && SAL_MAX_UINT16((sal_uInt16) 0xFFFF) != nActNumLvl; | |||
1190 | bool bSetValue = false; | |||
1191 | long nValue = 0; | |||
1192 | if (bOn || bSingleSelection) | |||
1193 | { | |||
1194 | sal_uInt16 nMask = 1; | |||
1195 | bool bFirst = true; | |||
1196 | bSetValue = true; | |||
1197 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
1198 | { | |||
1199 | if (nActNumLvl & nMask) | |||
1200 | { | |||
1201 | const SvxNumberFormat& rNumFmt = pActNum->GetLevel(i); | |||
1202 | if (bFirst) | |||
1203 | { | |||
1204 | nValue = rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset(); | |||
1205 | if (bOn && i) | |||
1206 | nValue -= (pActNum->GetLevel(i - 1).GetAbsLSpace() | |||
1207 | + pActNum->GetLevel(i - 1).GetFirstLineOffset()); | |||
1208 | } | |||
1209 | else | |||
1210 | bSetValue = nValue | |||
1211 | == (rNumFmt.GetAbsLSpace() + rNumFmt.GetFirstLineOffset()) | |||
1212 | - (pActNum->GetLevel(i - 1).GetAbsLSpace() | |||
1213 | + pActNum->GetLevel(i - 1).GetFirstLineOffset()); | |||
1214 | bFirst = false; | |||
1215 | } | |||
1216 | nMask <<= 1; | |||
1217 | } | |||
1218 | } | |||
1219 | if (bSetValue) | |||
1220 | SetMetricValue(*m_xDistBorderMF, nValue, eCoreUnit); | |||
1221 | else | |||
1222 | m_xDistBorderMF->set_text(""); | |||
1223 | m_xDistBorderMF->set_sensitive(bOn || bSingleSelection); | |||
1224 | m_xDistBorderFT->set_sensitive(bOn || bSingleSelection); | |||
1225 | bLastRelative = bOn; | |||
1226 | } | |||
1227 | ||||
1228 | void SvxBulletAndPositionDlg::EditModifyHdl_Impl(const weld::Entry* pEdit) | |||
1229 | { | |||
1230 | bool bPrefix = pEdit == m_xPrefixED.get(); | |||
1231 | bool bSuffix = pEdit == m_xSuffixED.get(); | |||
1232 | bool bStart = pEdit == m_xStartED.get(); | |||
1233 | sal_uInt16 nMask = 1; | |||
1234 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) | |||
1235 | { | |||
1236 | if (nActNumLvl & nMask) | |||
1237 | { | |||
1238 | SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); | |||
1239 | if (bPrefix) | |||
1240 | aNumFmt.SetPrefix(m_xPrefixED->get_text()); | |||
1241 | else if (bSuffix) | |||
1242 | aNumFmt.SetSuffix(m_xSuffixED->get_text()); | |||
1243 | else if (bStart) | |||
1244 | aNumFmt.SetStart(m_xStartED->get_value()); | |||
1245 | pActNum->SetLevel(i, aNumFmt); | |||
1246 | } | |||
1247 | nMask <<= 1; | |||
1248 | } | |||
1249 | SetModified(); | |||
1250 | } | |||
1251 | ||||
1252 | void SvxBulletAndPositionDlg::SetModified(bool bRepaint) | |||
1253 | { | |||
1254 | bModified = true; | |||
1255 | if (bRepaint) | |||
1256 | { | |||
1257 | m_aPreviewWIN.SetLevel(nActNumLvl); | |||
1258 | m_aPreviewWIN.Invalidate(); | |||
1259 | } | |||
1260 | } | |||
1261 | ||||
1262 | void SvxBulletAndPositionDlg::InitPosAndSpaceMode() | |||
1263 | { | |||
1264 | if (pActNum == nullptr) | |||
1265 | { | |||
1266 | SAL_WARN("cui.tabpages", "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of "do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "cui.tabpages")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cui.tabpages" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/dlg/BulletAndPositionDlg.cxx" ":" "1267" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cui.tabpages" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/dlg/BulletAndPositionDlg.cxx" ":" "1267" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cui.tabpages" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/dlg/BulletAndPositionDlg.cxx" ":" "1267" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cui.tabpages" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/dlg/BulletAndPositionDlg.cxx" ":" "1267" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | |||
1267 | "method -> <pAktNum> has to be already set!")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "cui.tabpages")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break ; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cui.tabpages" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/dlg/BulletAndPositionDlg.cxx" ":" "1267" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cui.tabpages" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/dlg/BulletAndPositionDlg.cxx" ":" "1267" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cui.tabpages" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/dlg/BulletAndPositionDlg.cxx" ":" "1267" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "<SvxNumPositionTabPage::InitPosAndSpaceMode()> - misusage of " "method -> <pAktNum> has to be already set!"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cui.tabpages" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/dlg/BulletAndPositionDlg.cxx" ":" "1267" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | |||
1268 | return; | |||
1269 | } | |||
1270 | ||||
1271 | SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode = SvxNumberFormat::LABEL_ALIGNMENT; | |||
1272 | sal_uInt16 nMask = 1; | |||
1273 | for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); ++i) | |||
1274 | { | |||
1275 | if (nActNumLvl & nMask) | |||
1276 | { | |||
1277 | SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); | |||
1278 | ePosAndSpaceMode = aNumFmt.GetPositionAndSpaceMode(); | |||
1279 | if (ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT) | |||
1280 | { | |||
1281 | break; | |||
1282 | } | |||
1283 | } | |||
1284 | nMask <<= 1; | |||
1285 | } | |||
1286 | ||||
1287 | bLabelAlignmentPosAndSpaceModeActive = ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT; | |||
1288 | } | |||
1289 | ||||
1290 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_PTR_HXX |
21 | #define INCLUDED_VCL_PTR_HXX |
22 | |
23 | #include <sal/config.h> |
24 | |
25 | #include <rtl/ref.hxx> |
26 | |
27 | #include <utility> |
28 | #include <type_traits> |
29 | |
30 | #ifdef DBG_UTIL |
31 | #ifndef _WIN32 |
32 | #include <vcl/vclmain.hxx> |
33 | #endif |
34 | #endif |
35 | |
36 | class VclReferenceBase; |
37 | |
38 | namespace vcl::detail { |
39 | |
40 | template<typename> |
41 | constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; } |
42 | |
43 | template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( |
44 | int (*)[sizeof(T)]) |
45 | { return std::is_base_of<VclReferenceBase, T>::value; } |
46 | |
47 | } // namespace vcl::detail |
48 | |
49 | /** |
50 | * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. |
51 | * |
52 | * For more details on the design please see vcl/README.lifecycle |
53 | * |
54 | * @param reference_type must be a subclass of vcl::Window |
55 | */ |
56 | template <class reference_type> |
57 | class VclPtr |
58 | { |
59 | static_assert( |
60 | vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>( |
61 | nullptr), |
62 | "template argument type must be derived from VclReferenceBase"); |
63 | |
64 | ::rtl::Reference<reference_type> m_rInnerRef; |
65 | |
66 | public: |
67 | /** Constructor... |
68 | */ |
69 | VclPtr() |
70 | : m_rInnerRef() |
71 | {} |
72 | |
73 | /** Constructor... |
74 | */ |
75 | VclPtr (reference_type * pBody) |
76 | : m_rInnerRef(pBody) |
77 | {} |
78 | |
79 | /** Constructor... that doesn't take a ref. |
80 | */ |
81 | VclPtr (reference_type * pBody, __sal_NoAcquire) |
82 | : m_rInnerRef(pBody, SAL_NO_ACQUIRE) |
83 | {} |
84 | |
85 | /** Up-casting conversion constructor: Copies interface reference. |
86 | |
87 | Does not work for up-casts to ambiguous bases. For the special case of |
88 | up-casting to Reference< XInterface >, see the corresponding conversion |
89 | operator. |
90 | |
91 | @param rRef another reference |
92 | */ |
93 | template< class derived_type > |
94 | VclPtr( |
95 | const VclPtr< derived_type > & rRef, |
96 | typename std::enable_if< |
97 | std::is_base_of<reference_type, derived_type>::value, int>::type |
98 | = 0 ) |
99 | : m_rInnerRef( static_cast<reference_type*>(rRef) ) |
100 | { |
101 | } |
102 | |
103 | #if defined(DBG_UTIL) && !defined(_WIN32) |
104 | virtual ~VclPtr() |
105 | { |
106 | assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain ::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 106, __extension__ __PRETTY_FUNCTION__)); |
107 | // We can be one of the intermediate counts, but if we are the last |
108 | // VclPtr keeping this object alive, then something forgot to call dispose(). |
109 | assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)) |
110 | && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)); |
111 | } |
112 | VclPtr(VclPtr const &) = default; |
113 | VclPtr(VclPtr &&) = default; |
114 | VclPtr & operator =(VclPtr const &) = default; |
115 | VclPtr & operator =(VclPtr &&) = default; |
116 | #endif |
117 | |
118 | /** |
119 | * A construction helper for VclPtr. Since VclPtr types are created |
120 | * with a reference-count of one - to help fit into the existing |
121 | * code-flow; this helps us to construct them easily. |
122 | * |
123 | * For more details on the design please see vcl/README.lifecycle |
124 | * |
125 | * @tparam reference_type must be a subclass of vcl::Window |
126 | */ |
127 | template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) |
128 | { |
129 | return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); |
130 | } |
131 | |
132 | /** Probably most common used: handle->someBodyOp(). |
133 | */ |
134 | reference_type * operator->() const |
135 | { |
136 | return m_rInnerRef.get(); |
137 | } |
138 | |
139 | /** Get the body. Can be used instead of operator->(). |
140 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() |
141 | are the same. |
142 | */ |
143 | reference_type * get() const |
144 | { |
145 | return m_rInnerRef.get(); |
146 | } |
147 | |
148 | void set(reference_type *pBody) |
149 | { |
150 | m_rInnerRef.set(pBody); |
151 | } |
152 | |
153 | void reset(reference_type *pBody) |
154 | { |
155 | m_rInnerRef.set(pBody); |
156 | } |
157 | |
158 | /** Up-casting copy assignment operator. |
159 | |
160 | Does not work for up-casts to ambiguous bases. |
161 | |
162 | @param rRef another reference |
163 | */ |
164 | template<typename derived_type> |
165 | typename std::enable_if< |
166 | std::is_base_of<reference_type, derived_type>::value, |
167 | VclPtr &>::type |
168 | operator =(VclPtr<derived_type> const & rRef) |
169 | { |
170 | m_rInnerRef.set(rRef.get()); |
171 | return *this; |
172 | } |
173 | |
174 | VclPtr & operator =(reference_type * pBody) |
175 | { |
176 | m_rInnerRef.set(pBody); |
177 | return *this; |
178 | } |
179 | |
180 | operator reference_type * () const |
181 | { |
182 | return m_rInnerRef.get(); |
183 | } |
184 | |
185 | explicit operator bool () const |
186 | { |
187 | return m_rInnerRef.get() != nullptr; |
188 | } |
189 | |
190 | void clear() |
191 | { |
192 | m_rInnerRef.clear(); |
193 | } |
194 | |
195 | void reset() |
196 | { |
197 | m_rInnerRef.clear(); |
198 | } |
199 | |
200 | void disposeAndClear() |
201 | { |
202 | // hold it alive for the lifetime of this method |
203 | ::rtl::Reference<reference_type> aTmp(m_rInnerRef); |
204 | m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-) |
205 | if (aTmp.get()) { |
206 | aTmp->disposeOnce(); |
207 | } |
208 | } |
209 | |
210 | /** Needed to place VclPtr's into STL collection. |
211 | */ |
212 | bool operator< (const VclPtr<reference_type> & handle) const |
213 | { |
214 | return (m_rInnerRef < handle.m_rInnerRef); |
215 | } |
216 | }; // class VclPtr |
217 | |
218 | template<typename T1, typename T2> |
219 | inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
220 | return p1.get() == p2.get(); |
221 | } |
222 | |
223 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2) |
224 | { |
225 | return p1.get() == p2; |
226 | } |
227 | |
228 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) { |
229 | return p1.get() == p2; |
230 | } |
231 | |
232 | template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2) |
233 | { |
234 | return p1 == p2.get(); |
235 | } |
236 | |
237 | template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { |
238 | return p1 == p2.get(); |
239 | } |
240 | |
241 | template<typename T1, typename T2> |
242 | inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
243 | return !(p1 == p2); |
244 | } |
245 | |
246 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) |
247 | { |
248 | return !(p1 == p2); |
249 | } |
250 | |
251 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { |
252 | return !(p1 == p2); |
253 | } |
254 | |
255 | template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) |
256 | { |
257 | return !(p1 == p2); |
258 | } |
259 | |
260 | template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { |
261 | return !(p1 == p2); |
262 | } |
263 | |
264 | /** |
265 | * A construction helper for a temporary VclPtr. Since VclPtr types |
266 | * are created with a reference-count of one - to help fit into |
267 | * the existing code-flow; this helps us to construct them easily. |
268 | * see also VclPtr::Create and ScopedVclPtr |
269 | * |
270 | * For more details on the design please see vcl/README.lifecycle |
271 | * |
272 | * @param reference_type must be a subclass of vcl::Window |
273 | */ |
274 | template <class reference_type> |
275 | class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type> |
276 | { |
277 | public: |
278 | template<typename... Arg> VclPtrInstance(Arg &&... arg) |
279 | : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
280 | { |
281 | } |
282 | |
283 | /** |
284 | * Override and disallow this, to prevent people accidentally calling it and actually |
285 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
286 | */ |
287 | template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; |
288 | }; |
289 | |
290 | template <class reference_type> |
291 | class ScopedVclPtr : public VclPtr<reference_type> |
292 | { |
293 | public: |
294 | /** Constructor... |
295 | */ |
296 | ScopedVclPtr() |
297 | : VclPtr<reference_type>() |
298 | {} |
299 | |
300 | /** Constructor |
301 | */ |
302 | ScopedVclPtr (reference_type * pBody) |
303 | : VclPtr<reference_type>(pBody) |
304 | {} |
305 | |
306 | /** Copy constructor... |
307 | */ |
308 | ScopedVclPtr (const VclPtr<reference_type> & handle) |
309 | : VclPtr<reference_type>(handle) |
310 | {} |
311 | |
312 | /** |
313 | Assignment that releases the last reference. |
314 | */ |
315 | void disposeAndReset(reference_type *pBody) |
316 | { |
317 | if (pBody != this->get()) { |
318 | VclPtr<reference_type>::disposeAndClear(); |
319 | VclPtr<reference_type>::set(pBody); |
320 | } |
321 | } |
322 | |
323 | /** |
324 | Assignment that releases the last reference. |
325 | */ |
326 | ScopedVclPtr<reference_type>& operator = (reference_type * pBody) |
327 | { |
328 | disposeAndReset(pBody); |
329 | return *this; |
330 | } |
331 | |
332 | /** Up-casting conversion constructor: Copies interface reference. |
333 | |
334 | Does not work for up-casts to ambiguous bases. For the special case of |
335 | up-casting to Reference< XInterface >, see the corresponding conversion |
336 | operator. |
337 | |
338 | @param rRef another reference |
339 | */ |
340 | template< class derived_type > |
341 | ScopedVclPtr( |
342 | const VclPtr< derived_type > & rRef, |
343 | typename std::enable_if< |
344 | std::is_base_of<reference_type, derived_type>::value, int>::type |
345 | = 0 ) |
346 | : VclPtr<reference_type>( rRef ) |
347 | { |
348 | } |
349 | |
350 | /** Up-casting assignment operator. |
351 | |
352 | Does not work for up-casts to ambiguous bases. |
353 | |
354 | @param rRef another VclPtr |
355 | */ |
356 | template<typename derived_type> |
357 | typename std::enable_if< |
358 | std::is_base_of<reference_type, derived_type>::value, |
359 | ScopedVclPtr &>::type |
360 | operator =(VclPtr<derived_type> const & rRef) |
361 | { |
362 | disposeAndReset(rRef.get()); |
363 | return *this; |
364 | } |
365 | |
366 | /** |
367 | * Override and disallow this, to prevent people accidentally calling it and actually |
368 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
369 | */ |
370 | template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; |
371 | |
372 | ~ScopedVclPtr() |
373 | { |
374 | VclPtr<reference_type>::disposeAndClear(); |
375 | assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get( ) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 375, __extension__ __PRETTY_FUNCTION__)); // make sure there are no lingering references |
376 | } |
377 | |
378 | private: |
379 | // Most likely we don't want this default copy-constructor. |
380 | ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete; |
381 | // And certainly we don't want a default assignment operator. |
382 | ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete; |
383 | // And disallow reset as that doesn't call disposeAndClear on the original reference |
384 | void reset() = delete; |
385 | void reset(reference_type *pBody) = delete; |
386 | |
387 | protected: |
388 | ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) |
389 | : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE) |
390 | {} |
391 | }; |
392 | |
393 | /** |
394 | * A construction helper for ScopedVclPtr. Since VclPtr types are created |
395 | * with a reference-count of one - to help fit into the existing |
396 | * code-flow; this helps us to construct them easily. |
397 | * |
398 | * For more details on the design please see vcl/README.lifecycle |
399 | * |
400 | * @param reference_type must be a subclass of vcl::Window |
401 | */ |
402 | #if defined _MSC_VER |
403 | #pragma warning(push) |
404 | #pragma warning(disable: 4521) // " multiple copy constructors specified" |
405 | #endif |
406 | template <class reference_type> |
407 | class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type> |
408 | { |
409 | public: |
410 | template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) |
411 | : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
412 | { |
413 | } |
414 | |
415 | /** |
416 | * Override and disallow this, to prevent people accidentally calling it and actually |
417 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
418 | */ |
419 | template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; |
420 | |
421 | private: |
422 | // Prevent the above perfect forwarding ctor from hijacking (accidental) |
423 | // attempts at ScopedVclPtrInstance copy construction (where the hijacking |
424 | // would typically lead to somewhat obscure error messages); both non-const |
425 | // and const variants are needed here, as the ScopedVclPtr base class has a |
426 | // const--variant copy ctor, so the implicitly declared copy ctor for |
427 | // ScopedVclPtrInstance would also be the const variant, so non-const copy |
428 | // construction attempts would be hijacked by the perfect forwarding ctor; |
429 | // but if we only declared a non-const variant here, the const variant would |
430 | // no longer be implicitly declared (as there would already be an explicitly |
431 | // declared copy ctor), so const copy construction attempts would then be |
432 | // hijacked by the perfect forwarding ctor: |
433 | ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete; |
434 | ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete; |
435 | }; |
436 | #if defined _MSC_VER |
437 | #pragma warning(pop) |
438 | #endif |
439 | |
440 | #endif // INCLUDED_VCL_PTR_HXX |
441 | |
442 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_RTL_REF_HXX | ||||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||||
22 | |||||||||
23 | #include "sal/config.h" | ||||||||
24 | |||||||||
25 | #include <cassert> | ||||||||
26 | #include <cstddef> | ||||||||
27 | #include <functional> | ||||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
29 | #include <type_traits> | ||||||||
30 | #endif | ||||||||
31 | |||||||||
32 | #include "sal/types.h" | ||||||||
33 | |||||||||
34 | namespace rtl | ||||||||
35 | { | ||||||||
36 | |||||||||
37 | /** Template reference class for reference type. | ||||||||
38 | */ | ||||||||
39 | template <class reference_type> | ||||||||
40 | class Reference | ||||||||
41 | { | ||||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||||
43 | */ | ||||||||
44 | reference_type * m_pBody; | ||||||||
45 | |||||||||
46 | |||||||||
47 | public: | ||||||||
48 | /** Constructor... | ||||||||
49 | */ | ||||||||
50 | Reference() | ||||||||
51 | : m_pBody (NULL__null) | ||||||||
52 | {} | ||||||||
53 | |||||||||
54 | |||||||||
55 | /** Constructor... | ||||||||
56 | */ | ||||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||||
58 | : m_pBody (pBody) | ||||||||
59 | { | ||||||||
60 | } | ||||||||
61 | |||||||||
62 | /** Constructor... | ||||||||
63 | */ | ||||||||
64 | Reference (reference_type * pBody) | ||||||||
65 | : m_pBody (pBody) | ||||||||
66 | { | ||||||||
67 | if (m_pBody) | ||||||||
68 | m_pBody->acquire(); | ||||||||
69 | } | ||||||||
70 | |||||||||
71 | /** Copy constructor... | ||||||||
72 | */ | ||||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||||
74 | : m_pBody (handle.m_pBody) | ||||||||
75 | { | ||||||||
76 | if (m_pBody) | ||||||||
77 | m_pBody->acquire(); | ||||||||
78 | } | ||||||||
79 | |||||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
81 | /** Move constructor... | ||||||||
82 | */ | ||||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||||
84 | : m_pBody (handle.m_pBody) | ||||||||
85 | { | ||||||||
86 | handle.m_pBody = nullptr; | ||||||||
87 | } | ||||||||
88 | #endif | ||||||||
89 | |||||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||||
92 | |||||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||||
94 | |||||||||
95 | @param rRef another reference | ||||||||
96 | */ | ||||||||
97 | template< class derived_type > | ||||||||
98 | inline Reference( | ||||||||
99 | const Reference< derived_type > & rRef, | ||||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||||
101 | : m_pBody (rRef.get()) | ||||||||
102 | { | ||||||||
103 | if (m_pBody) | ||||||||
104 | m_pBody->acquire(); | ||||||||
105 | } | ||||||||
106 | #endif | ||||||||
107 | |||||||||
108 | /** Destructor... | ||||||||
109 | */ | ||||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||||
111 | { | ||||||||
112 | if (m_pBody) | ||||||||
113 | m_pBody->release(); | ||||||||
114 | } | ||||||||
115 | |||||||||
116 | /** Set... | ||||||||
117 | Similar to assignment. | ||||||||
118 | */ | ||||||||
119 | Reference<reference_type> & | ||||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||||
121 | { | ||||||||
122 | if (pBody) | ||||||||
123 | pBody->acquire(); | ||||||||
124 | reference_type * const pOld = m_pBody; | ||||||||
125 | m_pBody = pBody; | ||||||||
126 | if (pOld) | ||||||||
127 | pOld->release(); | ||||||||
128 | return *this; | ||||||||
129 | } | ||||||||
130 | |||||||||
131 | /** Assignment. | ||||||||
132 | Unbinds this instance from its body (if bound) and | ||||||||
133 | bind it to the body represented by the handle. | ||||||||
134 | */ | ||||||||
135 | Reference<reference_type> & | ||||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||||
137 | { | ||||||||
138 | return set( handle.m_pBody ); | ||||||||
139 | } | ||||||||
140 | |||||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
142 | /** Assignment. | ||||||||
143 | * Unbinds this instance from its body (if bound), | ||||||||
144 | * bind it to the body represented by the handle, and | ||||||||
145 | * set the body represented by the handle to nullptr. | ||||||||
146 | */ | ||||||||
147 | Reference<reference_type> & | ||||||||
148 | operator= (Reference<reference_type> && handle) | ||||||||
149 | { | ||||||||
150 | // self-movement guts ourself | ||||||||
151 | if (m_pBody) | ||||||||
152 | m_pBody->release(); | ||||||||
153 | m_pBody = handle.m_pBody; | ||||||||
154 | handle.m_pBody = nullptr; | ||||||||
155 | return *this; | ||||||||
156 | } | ||||||||
157 | #endif | ||||||||
158 | |||||||||
159 | /** Assignment... | ||||||||
160 | */ | ||||||||
161 | Reference<reference_type> & | ||||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||||
163 | { | ||||||||
164 | return set( pBody ); | ||||||||
165 | } | ||||||||
166 | |||||||||
167 | /** Unbind the body from this handle. | ||||||||
168 | Note that for a handle representing a large body, | ||||||||
169 | "handle.clear().set(new body());" _might_ | ||||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||||
171 | since in the second case two large objects exist in memory | ||||||||
172 | (the old body and the new body). | ||||||||
173 | */ | ||||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||||
175 | { | ||||||||
176 | if (m_pBody
| ||||||||
177 | { | ||||||||
178 | reference_type * const pOld = m_pBody; | ||||||||
179 | m_pBody = NULL__null; | ||||||||
180 | pOld->release(); | ||||||||
181 | } | ||||||||
182 | return *this; | ||||||||
183 | } | ||||||||
184 | |||||||||
185 | |||||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||||
188 | are the same. | ||||||||
189 | */ | ||||||||
190 | reference_type * SAL_CALL get() const | ||||||||
191 | { | ||||||||
192 | return m_pBody; | ||||||||
| |||||||||
193 | } | ||||||||
194 | |||||||||
195 | |||||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||||
197 | */ | ||||||||
198 | reference_type * SAL_CALL operator->() const | ||||||||
199 | { | ||||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||||
201 | return m_pBody; | ||||||||
202 | } | ||||||||
203 | |||||||||
204 | |||||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||||
206 | */ | ||||||||
207 | reference_type & SAL_CALL operator*() const | ||||||||
208 | { | ||||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||||
210 | return *m_pBody; | ||||||||
211 | } | ||||||||
212 | |||||||||
213 | |||||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||||
215 | */ | ||||||||
216 | bool SAL_CALL is() const | ||||||||
217 | { | ||||||||
218 | return (m_pBody != NULL__null); | ||||||||
219 | } | ||||||||
220 | |||||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||||
223 | */ | ||||||||
224 | explicit operator bool() const | ||||||||
225 | { | ||||||||
226 | return is(); | ||||||||
227 | } | ||||||||
228 | #endif | ||||||||
229 | |||||||||
230 | /** Returns True if this points to pBody. | ||||||||
231 | */ | ||||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||||
233 | { | ||||||||
234 | return (m_pBody == pBody); | ||||||||
235 | } | ||||||||
236 | |||||||||
237 | |||||||||
238 | /** Returns True if handle points to the same body. | ||||||||
239 | */ | ||||||||
240 | bool | ||||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||||
242 | { | ||||||||
243 | return (m_pBody == handle.m_pBody); | ||||||||
244 | } | ||||||||
245 | |||||||||
246 | |||||||||
247 | /** Needed to place References into STL collection. | ||||||||
248 | */ | ||||||||
249 | bool | ||||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||||
251 | { | ||||||||
252 | return (m_pBody != handle.m_pBody); | ||||||||
253 | } | ||||||||
254 | |||||||||
255 | |||||||||
256 | /** Needed to place References into STL collection. | ||||||||
257 | */ | ||||||||
258 | bool | ||||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||||
260 | { | ||||||||
261 | return (m_pBody < handle.m_pBody); | ||||||||
262 | } | ||||||||
263 | |||||||||
264 | |||||||||
265 | /** Needed to place References into STL collection. | ||||||||
266 | */ | ||||||||
267 | bool | ||||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||||
269 | { | ||||||||
270 | return (m_pBody > handle.m_pBody); | ||||||||
271 | } | ||||||||
272 | }; | ||||||||
273 | |||||||||
274 | } // namespace rtl | ||||||||
275 | |||||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
277 | namespace std | ||||||||
278 | { | ||||||||
279 | |||||||||
280 | /// @cond INTERNAL | ||||||||
281 | /** | ||||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||||
283 | |||||||||
284 | @since LibreOffice 6.3 | ||||||||
285 | */ | ||||||||
286 | template<typename T> | ||||||||
287 | struct hash<::rtl::Reference<T>> | ||||||||
288 | { | ||||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||||
290 | { return std::size_t(s.get()); } | ||||||||
291 | }; | ||||||||
292 | /// @endcond | ||||||||
293 | |||||||||
294 | } | ||||||||
295 | |||||||||
296 | #endif | ||||||||
297 | |||||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||||
299 | |||||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_Reference_HXX |
20 | #define INCLUDED_VCL_Reference_HXX |
21 | |
22 | #include <vcl/dllapi.h> |
23 | #include <osl/interlck.h> |
24 | |
25 | class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase |
26 | { |
27 | mutable oslInterlockedCount mnRefCnt; |
28 | |
29 | template<typename T> friend class VclPtr; |
30 | |
31 | public: |
32 | void acquire() const |
33 | { |
34 | osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1); |
35 | } |
36 | |
37 | void release() const |
38 | { |
39 | if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0) |
40 | delete this; |
41 | } |
42 | #ifdef DBG_UTIL |
43 | #ifndef _WIN32 |
44 | sal_Int32 getRefCount() const { return mnRefCnt; } |
45 | #endif |
46 | #endif |
47 | |
48 | |
49 | private: |
50 | VclReferenceBase(const VclReferenceBase&) = delete; |
51 | VclReferenceBase& operator=(const VclReferenceBase&) = delete; |
52 | |
53 | bool mbDisposed : 1; |
54 | |
55 | protected: |
56 | VclReferenceBase(); |
57 | protected: |
58 | virtual ~VclReferenceBase(); |
59 | |
60 | protected: |
61 | virtual void dispose(); |
62 | |
63 | public: |
64 | void disposeOnce(); |
65 | bool isDisposed() const { return mbDisposed; } |
66 | |
67 | }; |
68 | #endif |