File: | home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx |
Warning: | line 2835, column 25 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 | |||||||||||||
10 | #include <config_feature_desktop.h> | ||||||||||||
11 | #include <config_options.h> | ||||||||||||
12 | |||||||||||||
13 | #include <memory> | ||||||||||||
14 | #include <unordered_map> | ||||||||||||
15 | #include <com/sun/star/accessibility/AccessibleRole.hpp> | ||||||||||||
16 | |||||||||||||
17 | #include <comphelper/lok.hxx> | ||||||||||||
18 | #include <i18nutil/unicode.hxx> | ||||||||||||
19 | #include <officecfg/Office/Common.hxx> | ||||||||||||
20 | #include <osl/module.hxx> | ||||||||||||
21 | #include <sal/log.hxx> | ||||||||||||
22 | #include <unotools/localedatawrapper.hxx> | ||||||||||||
23 | #include <unotools/resmgr.hxx> | ||||||||||||
24 | #include <vcl/builder.hxx> | ||||||||||||
25 | #include <vcl/toolkit/button.hxx> | ||||||||||||
26 | #include <vcl/toolkit/dialog.hxx> | ||||||||||||
27 | #include <vcl/toolkit/edit.hxx> | ||||||||||||
28 | #include <vcl/toolkit/field.hxx> | ||||||||||||
29 | #include <vcl/fieldvalues.hxx> | ||||||||||||
30 | #include <vcl/toolkit/fmtfield.hxx> | ||||||||||||
31 | #include <vcl/toolkit/fixed.hxx> | ||||||||||||
32 | #include <vcl/toolkit/fixedhyper.hxx> | ||||||||||||
33 | #include <vcl/headbar.hxx> | ||||||||||||
34 | #include <vcl/IPrioritable.hxx> | ||||||||||||
35 | #include <vcl/toolkit/ivctrl.hxx> | ||||||||||||
36 | #include <vcl/layout.hxx> | ||||||||||||
37 | #include <vcl/toolkit/lstbox.hxx> | ||||||||||||
38 | #include <vcl/menubtn.hxx> | ||||||||||||
39 | #include <vcl/mnemonic.hxx> | ||||||||||||
40 | #include <vcl/toolkit/prgsbar.hxx> | ||||||||||||
41 | #include <vcl/scrbar.hxx> | ||||||||||||
42 | #include <vcl/split.hxx> | ||||||||||||
43 | #include <vcl/svapp.hxx> | ||||||||||||
44 | #include <vcl/toolkit/svtabbx.hxx> | ||||||||||||
45 | #include <vcl/tabctrl.hxx> | ||||||||||||
46 | #include <vcl/tabpage.hxx> | ||||||||||||
47 | #include <vcl/toolkit/throbber.hxx> | ||||||||||||
48 | #include <vcl/toolbox.hxx> | ||||||||||||
49 | #include <vcl/toolkit/treelistentry.hxx> | ||||||||||||
50 | #include <vcl/toolkit/vclmedit.hxx> | ||||||||||||
51 | #include <vcl/settings.hxx> | ||||||||||||
52 | #include <slider.hxx> | ||||||||||||
53 | #include <vcl/weld.hxx> | ||||||||||||
54 | #include <vcl/weldutils.hxx> | ||||||||||||
55 | #include <vcl/commandinfoprovider.hxx> | ||||||||||||
56 | #include <iconview.hxx> | ||||||||||||
57 | #include <svdata.hxx> | ||||||||||||
58 | #include <bitmaps.hlst> | ||||||||||||
59 | #include <messagedialog.hxx> | ||||||||||||
60 | #include <OptionalBox.hxx> | ||||||||||||
61 | #include <window.h> | ||||||||||||
62 | #include <xmlreader/xmlreader.hxx> | ||||||||||||
63 | #include <desktop/crashreport.hxx> | ||||||||||||
64 | #include <calendar.hxx> | ||||||||||||
65 | #include <salinst.hxx> | ||||||||||||
66 | #include <strings.hrc> | ||||||||||||
67 | #include <treeglue.hxx> | ||||||||||||
68 | #include <tools/diagnose_ex.h> | ||||||||||||
69 | #include <verticaltabctrl.hxx> | ||||||||||||
70 | #include <wizdlg.hxx> | ||||||||||||
71 | #include <tools/svlibrary.h> | ||||||||||||
72 | #include <jsdialog/jsdialogbuilder.hxx> | ||||||||||||
73 | |||||||||||||
74 | #if defined(DISABLE_DYNLOADING) || defined(LINUX1) | ||||||||||||
75 | #include <dlfcn.h> | ||||||||||||
76 | #endif | ||||||||||||
77 | |||||||||||||
78 | static bool toBool(const OString &rValue) | ||||||||||||
79 | { | ||||||||||||
80 | return (!rValue.isEmpty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1')); | ||||||||||||
81 | } | ||||||||||||
82 | |||||||||||||
83 | namespace | ||||||||||||
84 | { | ||||||||||||
85 | OUString mapStockToImageResource(const OUString& sType) | ||||||||||||
86 | { | ||||||||||||
87 | if (sType == "gtk-index") | ||||||||||||
88 | return SV_RESID_BITMAP_INDEX"vcl/res/index.png"; | ||||||||||||
89 | else if (sType == "gtk-refresh") | ||||||||||||
90 | return SV_RESID_BITMAP_REFRESH"res/reload.png"; | ||||||||||||
91 | else if (sType == "gtk-apply") | ||||||||||||
92 | return IMG_APPLY"sw/res/sc20558.png"; | ||||||||||||
93 | else if (sType == "gtk-dialog-error") | ||||||||||||
94 | return IMG_ERROR"dbaccess/res/exerror.png"; | ||||||||||||
95 | else if (sType == "gtk-add") | ||||||||||||
96 | return IMG_ADD"extensions/res/scanner/plus.png"; | ||||||||||||
97 | else if (sType == "gtk-remove") | ||||||||||||
98 | return IMG_REMOVE"extensions/res/scanner/minus.png"; | ||||||||||||
99 | else if (sType == "gtk-copy") | ||||||||||||
100 | return IMG_COPY"cmd/sc_copy.png"; | ||||||||||||
101 | else if (sType == "gtk-paste") | ||||||||||||
102 | return IMG_PASTE"cmd/sc_paste.png"; | ||||||||||||
103 | return OUString(); | ||||||||||||
104 | } | ||||||||||||
105 | |||||||||||||
106 | SymbolType mapStockToSymbol(const OUString& sType) | ||||||||||||
107 | { | ||||||||||||
108 | SymbolType eRet = SymbolType::DONTKNOW; | ||||||||||||
109 | if (sType == "gtk-media-next") | ||||||||||||
110 | eRet = SymbolType::NEXT; | ||||||||||||
111 | else if (sType == "gtk-media-previous") | ||||||||||||
112 | eRet = SymbolType::PREV; | ||||||||||||
113 | else if (sType == "gtk-media-play") | ||||||||||||
114 | eRet = SymbolType::PLAY; | ||||||||||||
115 | else if (sType == "gtk-media-stop") | ||||||||||||
116 | eRet = SymbolType::STOP; | ||||||||||||
117 | else if (sType == "gtk-goto-first") | ||||||||||||
118 | eRet = SymbolType::FIRST; | ||||||||||||
119 | else if (sType == "gtk-goto-last") | ||||||||||||
120 | eRet = SymbolType::LAST; | ||||||||||||
121 | else if (sType == "gtk-go-back") | ||||||||||||
122 | eRet = SymbolType::ARROW_LEFT; | ||||||||||||
123 | else if (sType == "gtk-go-forward") | ||||||||||||
124 | eRet = SymbolType::ARROW_RIGHT; | ||||||||||||
125 | else if (sType == "gtk-go-up") | ||||||||||||
126 | eRet = SymbolType::ARROW_UP; | ||||||||||||
127 | else if (sType == "gtk-go-down") | ||||||||||||
128 | eRet = SymbolType::ARROW_DOWN; | ||||||||||||
129 | else if (sType == "gtk-missing-image") | ||||||||||||
130 | eRet = SymbolType::IMAGE; | ||||||||||||
131 | else if (sType == "gtk-help") | ||||||||||||
132 | eRet = SymbolType::HELP; | ||||||||||||
133 | else if (sType == "gtk-close") | ||||||||||||
134 | eRet = SymbolType::CLOSE; | ||||||||||||
135 | else if (sType == "gtk-new") | ||||||||||||
136 | eRet = SymbolType::PLUS; | ||||||||||||
137 | else if (!mapStockToImageResource(sType).isEmpty()) | ||||||||||||
138 | eRet = SymbolType::IMAGE; | ||||||||||||
139 | return eRet; | ||||||||||||
140 | } | ||||||||||||
141 | |||||||||||||
142 | void setupFromActionName(Button *pButton, VclBuilder::stringmap &rMap, const css::uno::Reference<css::frame::XFrame>& rFrame); | ||||||||||||
143 | } | ||||||||||||
144 | |||||||||||||
145 | #if defined SAL_LOG_WARN1 | ||||||||||||
146 | namespace | ||||||||||||
147 | { | ||||||||||||
148 | bool isButtonType(WindowType nType) | ||||||||||||
149 | { | ||||||||||||
150 | return nType == WindowType::PUSHBUTTON || | ||||||||||||
151 | nType == WindowType::OKBUTTON || | ||||||||||||
152 | nType == WindowType::CANCELBUTTON || | ||||||||||||
153 | nType == WindowType::HELPBUTTON || | ||||||||||||
154 | nType == WindowType::IMAGEBUTTON || | ||||||||||||
155 | nType == WindowType::MENUBUTTON || | ||||||||||||
156 | nType == WindowType::MOREBUTTON || | ||||||||||||
157 | nType == WindowType::SPINBUTTON; | ||||||||||||
158 | } | ||||||||||||
159 | } | ||||||||||||
160 | #endif | ||||||||||||
161 | |||||||||||||
162 | weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString &rUIFile, bool bMobile) | ||||||||||||
163 | { | ||||||||||||
164 | bool bUseJSBuilder = false; | ||||||||||||
165 | |||||||||||||
166 | if (bMobile) | ||||||||||||
167 | { | ||||||||||||
168 | if (rUIFile == "modules/swriter/ui/wordcount-mobile.ui" || | ||||||||||||
169 | rUIFile == "svx/ui/findreplacedialog-mobile.ui" || | ||||||||||||
170 | rUIFile == "modules/swriter/ui/watermarkdialog.ui" || | ||||||||||||
171 | rUIFile == "modules/scalc/ui/validationdialog.ui" || | ||||||||||||
172 | rUIFile == "modules/scalc/ui/validationcriteriapage.ui" || | ||||||||||||
173 | rUIFile == "modules/scalc/ui/validationhelptabpage-mobile.ui" || | ||||||||||||
174 | rUIFile == "modules/scalc/ui/erroralerttabpage-mobile.ui" || | ||||||||||||
175 | rUIFile == "modules/scalc/ui/validationdialog.ui") | ||||||||||||
176 | bUseJSBuilder = true; | ||||||||||||
177 | } | ||||||||||||
178 | |||||||||||||
179 | if (bUseJSBuilder) | ||||||||||||
180 | return new JSInstanceBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile); | ||||||||||||
181 | else | ||||||||||||
182 | return ImplGetSVData()->mpDefInst->CreateBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile); | ||||||||||||
183 | } | ||||||||||||
184 | |||||||||||||
185 | weld::Builder* Application::CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId) | ||||||||||||
186 | { | ||||||||||||
187 | if (comphelper::LibreOfficeKit::isActive() | ||||||||||||
188 | && (rUIFile == "svx/ui/stylespreview.ui" | ||||||||||||
189 | || rUIFile == "modules/scalc/ui/numberbox.ui")) | ||||||||||||
190 | { | ||||||||||||
191 | return new JSInstanceBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile, css::uno::Reference<css::frame::XFrame>(), nLOKWindowId); | ||||||||||||
192 | } | ||||||||||||
193 | |||||||||||||
194 | return ImplGetSVData()->mpDefInst->CreateInterimBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile, bAllowCycleFocusOut, nLOKWindowId); | ||||||||||||
195 | } | ||||||||||||
196 | |||||||||||||
197 | weld::MessageDialog* Application::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, | ||||||||||||
198 | VclButtonsType eButtonType, const OUString& rPrimaryMessage, | ||||||||||||
199 | bool bMobile) | ||||||||||||
200 | { | ||||||||||||
201 | if (bMobile) | ||||||||||||
202 | return JSInstanceBuilder::CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage); | ||||||||||||
203 | else | ||||||||||||
204 | return ImplGetSVData()->mpDefInst->CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage); | ||||||||||||
205 | } | ||||||||||||
206 | |||||||||||||
207 | weld::Window* Application::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) | ||||||||||||
208 | { | ||||||||||||
209 | return ImplGetSVData()->mpDefInst->GetFrameWeld(rWindow); | ||||||||||||
210 | } | ||||||||||||
211 | |||||||||||||
212 | namespace weld | ||||||||||||
213 | { | ||||||||||||
214 | OUString MetricSpinButton::MetricToString(FieldUnit rUnit) | ||||||||||||
215 | { | ||||||||||||
216 | const FieldUnitStringList& rList = ImplGetFieldUnits(); | ||||||||||||
217 | // return unit's default string (ie, the first one ) | ||||||||||||
218 | auto it = std::find_if( | ||||||||||||
219 | rList.begin(), rList.end(), | ||||||||||||
220 | [&rUnit](const std::pair<OUString, FieldUnit>& rItem) { return rItem.second == rUnit; }); | ||||||||||||
221 | if (it != rList.end()) | ||||||||||||
222 | return it->first; | ||||||||||||
223 | |||||||||||||
224 | return OUString(); | ||||||||||||
225 | } | ||||||||||||
226 | |||||||||||||
227 | IMPL_LINK_NOARG(MetricSpinButton, spin_button_value_changed, SpinButton&, void)void MetricSpinButton::LinkStubspin_button_value_changed(void * instance, SpinButton& data) { return static_cast<MetricSpinButton *>(instance)->spin_button_value_changed(data); } void MetricSpinButton ::spin_button_value_changed(__attribute__ ((unused)) SpinButton &) | ||||||||||||
228 | { | ||||||||||||
229 | signal_value_changed(); | ||||||||||||
230 | } | ||||||||||||
231 | |||||||||||||
232 | IMPL_LINK(MetricSpinButton, spin_button_output, SpinButton&, rSpinButton, void)void MetricSpinButton::LinkStubspin_button_output(void * instance , SpinButton& data) { return static_cast<MetricSpinButton *>(instance)->spin_button_output(data); } void MetricSpinButton ::spin_button_output(SpinButton& rSpinButton) | ||||||||||||
233 | { | ||||||||||||
234 | OUString sNewText(format_number(rSpinButton.get_value())); | ||||||||||||
235 | if (sNewText != rSpinButton.get_text()) | ||||||||||||
236 | rSpinButton.set_text(sNewText); | ||||||||||||
237 | } | ||||||||||||
238 | |||||||||||||
239 | void MetricSpinButton::update_width_chars() | ||||||||||||
240 | { | ||||||||||||
241 | int min, max; | ||||||||||||
242 | m_xSpinButton->get_range(min, max); | ||||||||||||
243 | auto width = std::max(m_xSpinButton->get_pixel_size(format_number(min)).Width(), | ||||||||||||
244 | m_xSpinButton->get_pixel_size(format_number(max)).Width()); | ||||||||||||
245 | int chars = ceil(width / m_xSpinButton->get_approximate_digit_width()); | ||||||||||||
246 | m_xSpinButton->set_width_chars(chars); | ||||||||||||
247 | } | ||||||||||||
248 | |||||||||||||
249 | unsigned int SpinButton::Power10(unsigned int n) | ||||||||||||
250 | { | ||||||||||||
251 | unsigned int nValue = 1; | ||||||||||||
252 | for (unsigned int i = 0; i < n; ++i) | ||||||||||||
253 | nValue *= 10; | ||||||||||||
254 | return nValue; | ||||||||||||
255 | } | ||||||||||||
256 | |||||||||||||
257 | int SpinButton::denormalize(int nValue) const | ||||||||||||
258 | { | ||||||||||||
259 | const int nFactor = Power10(get_digits()); | ||||||||||||
260 | |||||||||||||
261 | if ((nValue < (SAL_MIN_INT32((sal_Int32) (-0x7FFFFFFF - 1)) + nFactor)) || (nValue > (SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF) - nFactor))) | ||||||||||||
262 | { | ||||||||||||
263 | return nValue / nFactor; | ||||||||||||
264 | } | ||||||||||||
265 | |||||||||||||
266 | const int nHalf = nFactor / 2; | ||||||||||||
267 | |||||||||||||
268 | if (nValue < 0) | ||||||||||||
269 | return (nValue - nHalf) / nFactor; | ||||||||||||
270 | return (nValue + nHalf) / nFactor; | ||||||||||||
271 | } | ||||||||||||
272 | |||||||||||||
273 | OUString MetricSpinButton::format_number(int nValue) const | ||||||||||||
274 | { | ||||||||||||
275 | OUString aStr; | ||||||||||||
276 | |||||||||||||
277 | const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); | ||||||||||||
278 | |||||||||||||
279 | unsigned int nDecimalDigits = m_xSpinButton->get_digits(); | ||||||||||||
280 | //pawn percent off to icu to decide whether percent is separated from its number for this locale | ||||||||||||
281 | if (m_eSrcUnit == FieldUnit::PERCENT) | ||||||||||||
282 | { | ||||||||||||
283 | double fValue = nValue; | ||||||||||||
284 | fValue /= SpinButton::Power10(nDecimalDigits); | ||||||||||||
285 | aStr = unicode::formatPercent(fValue, rLocaleData.getLanguageTag()); | ||||||||||||
286 | } | ||||||||||||
287 | else | ||||||||||||
288 | { | ||||||||||||
289 | aStr = rLocaleData.getNum(nValue, nDecimalDigits, true, true); | ||||||||||||
290 | OUString aSuffix = MetricToString(m_eSrcUnit); | ||||||||||||
291 | if (m_eSrcUnit != FieldUnit::NONE && m_eSrcUnit != FieldUnit::DEGREE && m_eSrcUnit != FieldUnit::INCH && m_eSrcUnit != FieldUnit::FOOT) | ||||||||||||
292 | aStr += " "; | ||||||||||||
293 | if (m_eSrcUnit == FieldUnit::INCH) | ||||||||||||
294 | { | ||||||||||||
295 | OUString sDoublePrime = u"\u2033"; | ||||||||||||
296 | if (aSuffix != "\"" && aSuffix != sDoublePrime) | ||||||||||||
297 | aStr += " "; | ||||||||||||
298 | else | ||||||||||||
299 | aSuffix = sDoublePrime; | ||||||||||||
300 | } | ||||||||||||
301 | else if (m_eSrcUnit == FieldUnit::FOOT) | ||||||||||||
302 | { | ||||||||||||
303 | OUString sPrime = u"\u2032"; | ||||||||||||
304 | if (aSuffix != "'" && aSuffix != sPrime) | ||||||||||||
305 | aStr += " "; | ||||||||||||
306 | else | ||||||||||||
307 | aSuffix = sPrime; | ||||||||||||
308 | } | ||||||||||||
309 | |||||||||||||
310 | assert(m_eSrcUnit != FieldUnit::PERCENT)(static_cast <bool> (m_eSrcUnit != FieldUnit::PERCENT) ? void (0) : __assert_fail ("m_eSrcUnit != FieldUnit::PERCENT" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 310, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
311 | aStr += aSuffix; | ||||||||||||
312 | } | ||||||||||||
313 | |||||||||||||
314 | return aStr; | ||||||||||||
315 | } | ||||||||||||
316 | |||||||||||||
317 | void MetricSpinButton::set_digits(unsigned int digits) | ||||||||||||
318 | { | ||||||||||||
319 | int step, page; | ||||||||||||
320 | get_increments(step, page, m_eSrcUnit); | ||||||||||||
321 | int value = get_value(m_eSrcUnit); | ||||||||||||
322 | m_xSpinButton->set_digits(digits); | ||||||||||||
323 | set_increments(step, page, m_eSrcUnit); | ||||||||||||
324 | set_value(value, m_eSrcUnit); | ||||||||||||
325 | update_width_chars(); | ||||||||||||
326 | } | ||||||||||||
327 | |||||||||||||
328 | void MetricSpinButton::set_unit(FieldUnit eUnit) | ||||||||||||
329 | { | ||||||||||||
330 | if (eUnit != m_eSrcUnit) | ||||||||||||
331 | { | ||||||||||||
332 | int step, page; | ||||||||||||
333 | get_increments(step, page, m_eSrcUnit); | ||||||||||||
334 | int value = get_value(m_eSrcUnit); | ||||||||||||
335 | m_eSrcUnit = eUnit; | ||||||||||||
336 | set_increments(step, page, m_eSrcUnit); | ||||||||||||
337 | set_value(value, m_eSrcUnit); | ||||||||||||
338 | spin_button_output(*m_xSpinButton); | ||||||||||||
339 | update_width_chars(); | ||||||||||||
340 | } | ||||||||||||
341 | } | ||||||||||||
342 | |||||||||||||
343 | int MetricSpinButton::ConvertValue(int nValue, FieldUnit eInUnit, FieldUnit eOutUnit) const | ||||||||||||
344 | { | ||||||||||||
345 | auto nRet = vcl::ConvertValue(nValue, 0, m_xSpinButton->get_digits(), eInUnit, eOutUnit); | ||||||||||||
346 | if (nRet > SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF)) | ||||||||||||
347 | nRet = SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF); | ||||||||||||
348 | else if (nRet < SAL_MIN_INT32((sal_Int32) (-0x7FFFFFFF - 1))) | ||||||||||||
349 | nRet = SAL_MIN_INT32((sal_Int32) (-0x7FFFFFFF - 1)); | ||||||||||||
350 | return nRet; | ||||||||||||
351 | } | ||||||||||||
352 | |||||||||||||
353 | IMPL_LINK(MetricSpinButton, spin_button_input, int*, result, bool)bool MetricSpinButton::LinkStubspin_button_input(void * instance , int* data) { return static_cast<MetricSpinButton *>(instance )->spin_button_input(data); } bool MetricSpinButton::spin_button_input (int* result) | ||||||||||||
354 | { | ||||||||||||
355 | const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetLocaleDataWrapper(); | ||||||||||||
356 | double fResult(0.0); | ||||||||||||
357 | bool bRet = vcl::TextToValue(get_text(), fResult, 0, m_xSpinButton->get_digits(), rLocaleData, m_eSrcUnit); | ||||||||||||
358 | if (bRet) | ||||||||||||
359 | { | ||||||||||||
360 | if (fResult > SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF)) | ||||||||||||
361 | fResult = SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF); | ||||||||||||
362 | else if (fResult < SAL_MIN_INT32((sal_Int32) (-0x7FFFFFFF - 1))) | ||||||||||||
363 | fResult = SAL_MIN_INT32((sal_Int32) (-0x7FFFFFFF - 1)); | ||||||||||||
364 | *result = fResult; | ||||||||||||
365 | } | ||||||||||||
366 | return bRet; | ||||||||||||
367 | } | ||||||||||||
368 | |||||||||||||
369 | EntryTreeView::EntryTreeView(std::unique_ptr<Entry> xEntry, std::unique_ptr<TreeView> xTreeView) | ||||||||||||
370 | : m_xEntry(std::move(xEntry)) | ||||||||||||
371 | , m_xTreeView(std::move(xTreeView)) | ||||||||||||
372 | { | ||||||||||||
373 | m_xTreeView->connect_changed(LINK(this, EntryTreeView, ClickHdl)::tools::detail::makeLink( ::tools::detail::castTo<EntryTreeView *>(this), &EntryTreeView::LinkStubClickHdl)); | ||||||||||||
374 | m_xEntry->connect_changed(LINK(this, EntryTreeView, ModifyHdl)::tools::detail::makeLink( ::tools::detail::castTo<EntryTreeView *>(this), &EntryTreeView::LinkStubModifyHdl)); | ||||||||||||
375 | } | ||||||||||||
376 | |||||||||||||
377 | IMPL_LINK(EntryTreeView, ClickHdl, weld::TreeView&, rView, void)void EntryTreeView::LinkStubClickHdl(void * instance, weld::TreeView & data) { return static_cast<EntryTreeView *>(instance )->ClickHdl(data); } void EntryTreeView::ClickHdl(weld::TreeView & rView) | ||||||||||||
378 | { | ||||||||||||
379 | m_xEntry->set_text(rView.get_selected_text()); | ||||||||||||
380 | m_aChangeHdl.Call(*this); | ||||||||||||
381 | } | ||||||||||||
382 | |||||||||||||
383 | IMPL_LINK_NOARG(EntryTreeView, ModifyHdl, weld::Entry&, void)void EntryTreeView::LinkStubModifyHdl(void * instance, weld:: Entry& data) { return static_cast<EntryTreeView *>( instance)->ModifyHdl(data); } void EntryTreeView::ModifyHdl (__attribute__ ((unused)) weld::Entry&) | ||||||||||||
384 | { | ||||||||||||
385 | m_aChangeHdl.Call(*this); | ||||||||||||
386 | } | ||||||||||||
387 | |||||||||||||
388 | void EntryTreeView::set_height_request_by_rows(int nRows) | ||||||||||||
389 | { | ||||||||||||
390 | int nHeight = nRows == -1 ? -1 : m_xTreeView->get_height_rows(nRows); | ||||||||||||
391 | m_xTreeView->set_size_request(m_xTreeView->get_size_request().Width(), nHeight); | ||||||||||||
392 | } | ||||||||||||
393 | |||||||||||||
394 | size_t GetAbsPos(const weld::TreeView& rTreeView, const weld::TreeIter& rIter) | ||||||||||||
395 | { | ||||||||||||
396 | size_t nAbsPos = 0; | ||||||||||||
397 | |||||||||||||
398 | std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator(&rIter)); | ||||||||||||
399 | if (!rTreeView.get_iter_first(*xEntry)) | ||||||||||||
400 | xEntry.reset(); | ||||||||||||
401 | |||||||||||||
402 | while (xEntry && rTreeView.iter_compare(*xEntry, rIter) != 0) | ||||||||||||
403 | { | ||||||||||||
404 | if (!rTreeView.iter_next(*xEntry)) | ||||||||||||
405 | xEntry.reset(); | ||||||||||||
406 | nAbsPos++; | ||||||||||||
407 | } | ||||||||||||
408 | |||||||||||||
409 | return nAbsPos; | ||||||||||||
410 | } | ||||||||||||
411 | |||||||||||||
412 | bool IsEntryVisible(const weld::TreeView& rTreeView, const weld::TreeIter& rIter) | ||||||||||||
413 | { | ||||||||||||
414 | // short circuit for the common case | ||||||||||||
415 | if (rTreeView.get_iter_depth(rIter) == 0) | ||||||||||||
416 | return true; | ||||||||||||
417 | |||||||||||||
418 | std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator(&rIter)); | ||||||||||||
419 | bool bRetVal = false; | ||||||||||||
420 | do | ||||||||||||
421 | { | ||||||||||||
422 | if (rTreeView.get_iter_depth(*xEntry) == 0) | ||||||||||||
423 | { | ||||||||||||
424 | bRetVal = true; | ||||||||||||
425 | break; | ||||||||||||
426 | } | ||||||||||||
427 | } while (rTreeView.iter_parent(*xEntry) && rTreeView.get_row_expanded(*xEntry)); | ||||||||||||
428 | return bRetVal; | ||||||||||||
429 | } | ||||||||||||
430 | } | ||||||||||||
431 | |||||||||||||
432 | VclBuilder::VclBuilder(vcl::Window* pParent, const OUString& sUIDir, const OUString& sUIFile, | ||||||||||||
433 | const OString& sID, const css::uno::Reference<css::frame::XFrame>& rFrame, | ||||||||||||
434 | bool bLegacy, const NotebookBarAddonsItem* pNotebookBarAddonsItem) | ||||||||||||
435 | : m_pNotebookBarAddonsItem(pNotebookBarAddonsItem | ||||||||||||
| |||||||||||||
436 | ? new NotebookBarAddonsItem(*pNotebookBarAddonsItem) | ||||||||||||
437 | : new NotebookBarAddonsItem{}) | ||||||||||||
438 | , m_sID(sID) | ||||||||||||
439 | , m_sHelpRoot(OUStringToOString(sUIFile, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))) | ||||||||||||
440 | , m_pStringReplace(Translate::GetReadStringHook()) | ||||||||||||
441 | , m_pParent(pParent) | ||||||||||||
442 | , m_bToplevelParentFound(false) | ||||||||||||
443 | , m_bLegacy(bLegacy) | ||||||||||||
444 | , m_pParserState(new ParserState) | ||||||||||||
445 | , m_xFrame(rFrame) | ||||||||||||
446 | { | ||||||||||||
447 | m_bToplevelHasDeferredInit = pParent
| ||||||||||||
448 | ((pParent->IsSystemWindow() && static_cast<SystemWindow*>(pParent)->isDeferredInit()) || | ||||||||||||
449 | (pParent->IsDockingWindow() && static_cast<DockingWindow*>(pParent)->isDeferredInit())); | ||||||||||||
450 | m_bToplevelHasDeferredProperties = m_bToplevelHasDeferredInit; | ||||||||||||
451 | |||||||||||||
452 | sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.'); | ||||||||||||
453 | if (nIdx != -1) | ||||||||||||
454 | m_sHelpRoot = m_sHelpRoot.copy(0, nIdx); | ||||||||||||
455 | m_sHelpRoot += OString('/'); | ||||||||||||
456 | |||||||||||||
457 | OUString sUri = sUIDir + sUIFile; | ||||||||||||
458 | |||||||||||||
459 | try | ||||||||||||
460 | { | ||||||||||||
461 | xmlreader::XmlReader reader(sUri); | ||||||||||||
462 | |||||||||||||
463 | handleChild(pParent, nullptr, reader); | ||||||||||||
464 | } | ||||||||||||
465 | catch (const css::uno::Exception &rExcept) | ||||||||||||
466 | { | ||||||||||||
467 | DBG_UNHANDLED_EXCEPTION("vcl.builder", "Unable to read .ui file")DbgUnhandledException( DbgGetCaughtException(), __func__, "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "467" ": ", "vcl.builder", "Unable to read .ui file" );; | ||||||||||||
468 | CrashReporter::addKeyValue("VclBuilderException", "Unable to read .ui file: " + rExcept.Message, CrashReporter::Write); | ||||||||||||
469 | throw; | ||||||||||||
470 | } | ||||||||||||
471 | |||||||||||||
472 | //Set Mnemonic widgets when everything has been imported | ||||||||||||
473 | for (auto const& mnemonicWidget : m_pParserState->m_aMnemonicWidgetMaps) | ||||||||||||
474 | { | ||||||||||||
475 | FixedText *pOne = get<FixedText>(mnemonicWidget.m_sID); | ||||||||||||
476 | vcl::Window *pOther = get(mnemonicWidget.m_sValue.toUtf8()); | ||||||||||||
477 | SAL_WARN_IF(!pOne || !pOther, "vcl", "missing either source " << mnemonicWidget.m_sIDdo { if (true && (!pOne || !pOther)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing either source " << mnemonicWidget.m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "478" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing either source " << mnemonicWidget .m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing either source " << mnemonicWidget.m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "478" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing either source " << mnemonicWidget. m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "478" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing either source " << mnemonicWidget .m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing either source " << mnemonicWidget.m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "478" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | ||||||||||||
478 | << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping")do { if (true && (!pOne || !pOther)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing either source " << mnemonicWidget.m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "478" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing either source " << mnemonicWidget .m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing either source " << mnemonicWidget.m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "478" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing either source " << mnemonicWidget. m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "478" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing either source " << mnemonicWidget .m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing either source " << mnemonicWidget.m_sID << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "478" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
479 | if (pOne && pOther) | ||||||||||||
480 | pOne->set_mnemonic_widget(pOther); | ||||||||||||
481 | } | ||||||||||||
482 | |||||||||||||
483 | //Set a11y relations and role when everything has been imported | ||||||||||||
484 | for (auto const& elemAtk : m_pParserState->m_aAtkInfo) | ||||||||||||
485 | { | ||||||||||||
486 | vcl::Window *pSource = elemAtk.first; | ||||||||||||
487 | const stringmap &rMap = elemAtk.second; | ||||||||||||
488 | |||||||||||||
489 | for (auto const& elemMap : rMap) | ||||||||||||
490 | { | ||||||||||||
491 | const OString &rType = elemMap.first; | ||||||||||||
492 | const OUString &rParam = elemMap.second; | ||||||||||||
493 | if (rType == "role") | ||||||||||||
494 | { | ||||||||||||
495 | sal_Int16 role = BuilderUtils::getRoleFromName(rParam.toUtf8()); | ||||||||||||
496 | if (role != com::sun::star::accessibility::AccessibleRole::UNKNOWN) | ||||||||||||
497 | pSource->SetAccessibleRole(role); | ||||||||||||
498 | } | ||||||||||||
499 | else | ||||||||||||
500 | { | ||||||||||||
501 | vcl::Window *pTarget = get(rParam.toUtf8()); | ||||||||||||
502 | SAL_WARN_IF(!pTarget, "vcl", "missing parameter of a11y relation: " << rParam)do { if (true && (!pTarget)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing parameter of a11y relation: " << rParam) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "502" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing parameter of a11y relation: " << rParam), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "missing parameter of a11y relation: " << rParam; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "502" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing parameter of a11y relation: " << rParam ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "502" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing parameter of a11y relation: " << rParam), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "missing parameter of a11y relation: " << rParam; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "502" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
503 | if (!pTarget) | ||||||||||||
504 | continue; | ||||||||||||
505 | if (rType == "labelled-by") | ||||||||||||
506 | pSource->SetAccessibleRelationLabeledBy(pTarget); | ||||||||||||
507 | else if (rType == "label-for") | ||||||||||||
508 | pSource->SetAccessibleRelationLabelFor(pTarget); | ||||||||||||
509 | else if (rType == "member-of") | ||||||||||||
510 | pSource->SetAccessibleRelationMemberOf(pTarget); | ||||||||||||
511 | else | ||||||||||||
512 | { | ||||||||||||
513 | SAL_WARN("vcl.builder", "unhandled a11y relation :" << rType)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled a11y relation :" << rType) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "513" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "unhandled a11y relation :" << rType ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled a11y relation :" << rType; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ( "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "513" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled a11y relation :" << rType) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "513" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "unhandled a11y relation :" << rType ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled a11y relation :" << rType; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ( "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "513" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
514 | } | ||||||||||||
515 | } | ||||||||||||
516 | } | ||||||||||||
517 | } | ||||||||||||
518 | |||||||||||||
519 | //Set radiobutton groups when everything has been imported | ||||||||||||
520 | for (auto const& elem : m_pParserState->m_aGroupMaps) | ||||||||||||
521 | { | ||||||||||||
522 | RadioButton *pOne = get<RadioButton>(elem.m_sID); | ||||||||||||
523 | RadioButton *pOther = get<RadioButton>(elem.m_sValue); | ||||||||||||
524 | SAL_WARN_IF(!pOne || !pOther, "vcl", "missing member of radiobutton group")do { if (true && (!pOne || !pOther)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing member of radiobutton group" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "524" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing member of radiobutton group") , 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing member of radiobutton group"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "524" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing member of radiobutton group") == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "524" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing member of radiobutton group") , 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing member of radiobutton group"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "524" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
525 | if (pOne && pOther) | ||||||||||||
526 | { | ||||||||||||
527 | if (m_bLegacy) | ||||||||||||
528 | pOne->group(*pOther); | ||||||||||||
529 | else | ||||||||||||
530 | { | ||||||||||||
531 | pOther->group(*pOne); | ||||||||||||
532 | std::stable_sort(pOther->m_xGroup->begin(), pOther->m_xGroup->end(), sortIntoBestTabTraversalOrder(this)); | ||||||||||||
533 | } | ||||||||||||
534 | } | ||||||||||||
535 | } | ||||||||||||
536 | |||||||||||||
537 | //Set ComboBox models when everything has been imported | ||||||||||||
538 | for (auto const& elem : m_pParserState->m_aModelMaps) | ||||||||||||
539 | { | ||||||||||||
540 | vcl::Window* pTarget = get(elem.m_sID); | ||||||||||||
541 | ListBox *pListBoxTarget = dynamic_cast<ListBox*>(pTarget); | ||||||||||||
542 | ComboBox *pComboBoxTarget = dynamic_cast<ComboBox*>(pTarget); | ||||||||||||
543 | SvTabListBox *pTreeBoxTarget = dynamic_cast<SvTabListBox*>(pTarget); | ||||||||||||
544 | // pStore may be empty | ||||||||||||
545 | const ListStore *pStore = get_model_by_name(elem.m_sValue.toUtf8()); | ||||||||||||
546 | SAL_WARN_IF(!pListBoxTarget && !pComboBoxTarget && !pTreeBoxTarget, "vcl", "missing elements of combobox")do { if (true && (!pListBoxTarget && !pComboBoxTarget && !pTreeBoxTarget)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing elements of combobox" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "546" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of combobox"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of combobox"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "546" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of combobox") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "546" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of combobox"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of combobox"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "546" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
547 | if (pListBoxTarget && pStore) | ||||||||||||
548 | mungeModel(*pListBoxTarget, *pStore, elem.m_nActiveId); | ||||||||||||
549 | else if (pComboBoxTarget && pStore) | ||||||||||||
550 | mungeModel(*pComboBoxTarget, *pStore, elem.m_nActiveId); | ||||||||||||
551 | else if (pTreeBoxTarget && pStore) | ||||||||||||
552 | mungeModel(*pTreeBoxTarget, *pStore, elem.m_nActiveId); | ||||||||||||
553 | } | ||||||||||||
554 | |||||||||||||
555 | //Set TextView buffers when everything has been imported | ||||||||||||
556 | for (auto const& elem : m_pParserState->m_aTextBufferMaps) | ||||||||||||
557 | { | ||||||||||||
558 | VclMultiLineEdit *pTarget = get<VclMultiLineEdit>(elem.m_sID); | ||||||||||||
559 | const TextBuffer *pBuffer = get_buffer_by_name(elem.m_sValue.toUtf8()); | ||||||||||||
560 | SAL_WARN_IF(!pTarget || !pBuffer, "vcl", "missing elements of textview/textbuffer")do { if (true && (!pTarget || !pBuffer)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing elements of textview/textbuffer" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "560" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of textview/textbuffer" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of textview/textbuffer"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "560" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of textview/textbuffer") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "560" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of textview/textbuffer" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of textview/textbuffer"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "560" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
561 | if (pTarget && pBuffer) | ||||||||||||
562 | mungeTextBuffer(*pTarget, *pBuffer); | ||||||||||||
563 | } | ||||||||||||
564 | |||||||||||||
565 | //Set SpinButton adjustments when everything has been imported | ||||||||||||
566 | for (auto const& elem : m_pParserState->m_aNumericFormatterAdjustmentMaps) | ||||||||||||
567 | { | ||||||||||||
568 | NumericFormatter *pTarget = dynamic_cast<NumericFormatter*>(get(elem.m_sID)); | ||||||||||||
569 | const Adjustment *pAdjustment = get_adjustment_by_name(elem.m_sValue.toUtf8()); | ||||||||||||
570 | SAL_WARN_IF(!pTarget, "vcl", "missing NumericFormatter element of spinbutton/adjustment")do { if (true && (!pTarget)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing NumericFormatter element of spinbutton/adjustment" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "570" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing NumericFormatter element of spinbutton/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing NumericFormatter element of spinbutton/adjustment" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "570" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing NumericFormatter element of spinbutton/adjustment" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "570" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing NumericFormatter element of spinbutton/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing NumericFormatter element of spinbutton/adjustment" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "570" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
571 | SAL_WARN_IF(!pAdjustment, "vcl", "missing Adjustment element of spinbutton/adjustment")do { if (true && (!pAdjustment)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing Adjustment element of spinbutton/adjustment" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "571" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing Adjustment element of spinbutton/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing Adjustment element of spinbutton/adjustment" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "571" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing Adjustment element of spinbutton/adjustment" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "571" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing Adjustment element of spinbutton/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing Adjustment element of spinbutton/adjustment" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "571" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
572 | if (pTarget && pAdjustment) | ||||||||||||
573 | mungeAdjustment(*pTarget, *pAdjustment); | ||||||||||||
574 | } | ||||||||||||
575 | |||||||||||||
576 | for (auto const& elem : m_pParserState->m_aFormattedFormatterAdjustmentMaps) | ||||||||||||
577 | { | ||||||||||||
578 | FormattedField *pTarget = dynamic_cast<FormattedField*>(get(elem.m_sID)); | ||||||||||||
579 | const Adjustment *pAdjustment = get_adjustment_by_name(elem.m_sValue.toUtf8()); | ||||||||||||
580 | SAL_WARN_IF(!pTarget, "vcl", "missing FormattedField element of spinbutton/adjustment")do { if (true && (!pTarget)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing FormattedField element of spinbutton/adjustment" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "580" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing FormattedField element of spinbutton/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing FormattedField element of spinbutton/adjustment" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "580" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing FormattedField element of spinbutton/adjustment" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "580" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing FormattedField element of spinbutton/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing FormattedField element of spinbutton/adjustment" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "580" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
581 | SAL_WARN_IF(!pAdjustment, "vcl", "missing Adjustment element of spinbutton/adjustment")do { if (true && (!pAdjustment)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing Adjustment element of spinbutton/adjustment" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "581" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing Adjustment element of spinbutton/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing Adjustment element of spinbutton/adjustment" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "581" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing Adjustment element of spinbutton/adjustment" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "581" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing Adjustment element of spinbutton/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing Adjustment element of spinbutton/adjustment" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "581" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
582 | if (pTarget && pAdjustment) | ||||||||||||
583 | mungeAdjustment(*pTarget, *pAdjustment); | ||||||||||||
584 | } | ||||||||||||
585 | |||||||||||||
586 | //Set ScrollBar adjustments when everything has been imported | ||||||||||||
587 | for (auto const& elem : m_pParserState->m_aScrollAdjustmentMaps) | ||||||||||||
588 | { | ||||||||||||
589 | ScrollBar *pTarget = get<ScrollBar>(elem.m_sID); | ||||||||||||
590 | const Adjustment *pAdjustment = get_adjustment_by_name(elem.m_sValue.toUtf8()); | ||||||||||||
591 | SAL_WARN_IF(!pTarget || !pAdjustment, "vcl", "missing elements of scrollbar/adjustment")do { if (true && (!pTarget || !pAdjustment)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of scrollbar/adjustment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ( "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "591" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of scrollbar/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of scrollbar/adjustment"; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "591" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of scrollbar/adjustment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ( "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "591" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of scrollbar/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of scrollbar/adjustment"; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "591" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
592 | if (pTarget && pAdjustment) | ||||||||||||
593 | mungeAdjustment(*pTarget, *pAdjustment); | ||||||||||||
594 | } | ||||||||||||
595 | |||||||||||||
596 | //Set Scale(Slider) adjustments | ||||||||||||
597 | for (auto const& elem : m_pParserState->m_aSliderAdjustmentMaps) | ||||||||||||
598 | { | ||||||||||||
599 | Slider* pTarget = dynamic_cast<Slider*>(get(elem.m_sID)); | ||||||||||||
600 | const Adjustment* pAdjustment = get_adjustment_by_name(elem.m_sValue.toUtf8()); | ||||||||||||
601 | SAL_WARN_IF(!pTarget || !pAdjustment, "vcl", "missing elements of scale(slider)/adjustment")do { if (true && (!pTarget || !pAdjustment)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of scale(slider)/adjustment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "601" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of scale(slider)/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of scale(slider)/adjustment"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "601" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of scale(slider)/adjustment") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "601" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of scale(slider)/adjustment" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of scale(slider)/adjustment"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "601" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
602 | if (pTarget && pAdjustment) | ||||||||||||
603 | { | ||||||||||||
604 | mungeAdjustment(*pTarget, *pAdjustment); | ||||||||||||
605 | } | ||||||||||||
606 | } | ||||||||||||
607 | |||||||||||||
608 | //Set size-groups when all widgets have been imported | ||||||||||||
609 | for (auto const& sizeGroup : m_pParserState->m_aSizeGroups) | ||||||||||||
610 | { | ||||||||||||
611 | std::shared_ptr<VclSizeGroup> xGroup(std::make_shared<VclSizeGroup>()); | ||||||||||||
612 | |||||||||||||
613 | for (auto const& elem : sizeGroup.m_aProperties) | ||||||||||||
614 | { | ||||||||||||
615 | const OString &rKey = elem.first; | ||||||||||||
616 | const OUString &rValue = elem.second; | ||||||||||||
617 | xGroup->set_property(rKey, rValue); | ||||||||||||
618 | } | ||||||||||||
619 | |||||||||||||
620 | for (auto const& elem : sizeGroup.m_aWidgets) | ||||||||||||
621 | { | ||||||||||||
622 | vcl::Window* pWindow = get(elem.getStr()); | ||||||||||||
623 | pWindow->add_to_size_group(xGroup); | ||||||||||||
624 | } | ||||||||||||
625 | } | ||||||||||||
626 | |||||||||||||
627 | //Set button images when everything has been imported | ||||||||||||
628 | std::set<OUString> aImagesToBeRemoved; | ||||||||||||
629 | for (auto const& elem : m_pParserState->m_aButtonImageWidgetMaps) | ||||||||||||
630 | { | ||||||||||||
631 | PushButton *pTargetButton = nullptr; | ||||||||||||
632 | RadioButton *pTargetRadio = nullptr; | ||||||||||||
633 | Button *pTarget = nullptr; | ||||||||||||
634 | |||||||||||||
635 | if (!elem.m_bRadio) | ||||||||||||
636 | { | ||||||||||||
637 | pTargetButton = get<PushButton>(elem.m_sID); | ||||||||||||
638 | pTarget = pTargetButton; | ||||||||||||
639 | } | ||||||||||||
640 | else | ||||||||||||
641 | { | ||||||||||||
642 | pTargetRadio = get<RadioButton>(elem.m_sID); | ||||||||||||
643 | pTarget = pTargetRadio; | ||||||||||||
644 | } | ||||||||||||
645 | |||||||||||||
646 | FixedImage *pImage = get<FixedImage>(elem.m_sValue.toUtf8()); | ||||||||||||
647 | SAL_WARN_IF(!pTarget || !pImage,do { if (true && (!pTarget || !pImage)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing elements of button/image/stock" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "648" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of button/image/stock" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of button/image/stock"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "648" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of button/image/stock") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "648" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of button/image/stock" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of button/image/stock"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "648" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | ||||||||||||
648 | "vcl", "missing elements of button/image/stock")do { if (true && (!pTarget || !pImage)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing elements of button/image/stock" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "648" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of button/image/stock" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of button/image/stock"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "648" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of button/image/stock") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "648" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of button/image/stock" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of button/image/stock"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "648" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
649 | if (!pTarget || !pImage) | ||||||||||||
650 | continue; | ||||||||||||
651 | aImagesToBeRemoved.insert(elem.m_sValue); | ||||||||||||
652 | |||||||||||||
653 | VclBuilder::StockMap::iterator aFind = m_pParserState->m_aStockMap.find(elem.m_sValue.toUtf8()); | ||||||||||||
654 | if (aFind == m_pParserState->m_aStockMap.end()) | ||||||||||||
655 | { | ||||||||||||
656 | if (!elem.m_bRadio) | ||||||||||||
657 | { | ||||||||||||
658 | pTargetButton->SetModeImage(pImage->GetImage()); | ||||||||||||
659 | if (pImage->GetStyle() & WB_SMALLSTYLE) | ||||||||||||
660 | { | ||||||||||||
661 | pTargetButton->SetStyle(pTargetButton->GetStyle() | WB_SMALLSTYLE); | ||||||||||||
662 | Size aSz(pTargetButton->GetModeImage().GetSizePixel()); | ||||||||||||
663 | aSz.AdjustWidth(6); | ||||||||||||
664 | aSz.AdjustHeight(6); | ||||||||||||
665 | if (pTargetButton->get_width_request() == -1) | ||||||||||||
666 | pTargetButton->set_width_request(aSz.Width()); | ||||||||||||
667 | if (pTargetButton->get_height_request() == -1) | ||||||||||||
668 | pTargetButton->set_height_request(aSz.Height()); | ||||||||||||
669 | } | ||||||||||||
670 | } | ||||||||||||
671 | else | ||||||||||||
672 | pTargetRadio->SetModeRadioImage(pImage->GetImage()); | ||||||||||||
673 | } | ||||||||||||
674 | else | ||||||||||||
675 | { | ||||||||||||
676 | const stockinfo &rImageInfo = aFind->second; | ||||||||||||
677 | SymbolType eType = mapStockToSymbol(rImageInfo.m_sStock); | ||||||||||||
678 | SAL_WARN_IF(eType == SymbolType::DONTKNOW, "vcl", "missing stock image element for button")do { if (true && (eType == SymbolType::DONTKNOW)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing stock image element for button") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "678" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing stock image element for button" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing stock image element for button"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "678" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing stock image element for button") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "678" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing stock image element for button" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing stock image element for button"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "678" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
679 | if (eType == SymbolType::DONTKNOW) | ||||||||||||
680 | continue; | ||||||||||||
681 | if (!elem.m_bRadio) | ||||||||||||
682 | { | ||||||||||||
683 | pTargetButton->SetSymbol(eType); | ||||||||||||
684 | //fdo#76457 keep symbol images small e.g. tools->customize->menu | ||||||||||||
685 | //but images the right size. Really the PushButton::CalcMinimumSize | ||||||||||||
686 | //and PushButton::ImplDrawPushButton are the better place to handle | ||||||||||||
687 | //this, but its such a train-wreck | ||||||||||||
688 | if (eType != SymbolType::IMAGE) | ||||||||||||
689 | pTargetButton->SetStyle(pTargetButton->GetStyle() | WB_SMALLSTYLE); | ||||||||||||
690 | } | ||||||||||||
691 | else | ||||||||||||
692 | SAL_WARN_IF(eType != SymbolType::IMAGE, "vcl.builder", "unimplemented symbol type for radiobuttons")do { if (true && (eType != SymbolType::IMAGE)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN, "vcl.builder" )) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unimplemented symbol type for radiobuttons") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "692" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "unimplemented symbol type for radiobuttons" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unimplemented symbol type for radiobuttons"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder") , ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "692" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unimplemented symbol type for radiobuttons") == 1 ) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "692" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "unimplemented symbol type for radiobuttons" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unimplemented symbol type for radiobuttons"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder") , ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "692" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
693 | if (eType == SymbolType::IMAGE) | ||||||||||||
694 | { | ||||||||||||
695 | Image const aImage(StockImage::Yes, | ||||||||||||
696 | mapStockToImageResource(rImageInfo.m_sStock)); | ||||||||||||
697 | if (!elem.m_bRadio) | ||||||||||||
698 | pTargetButton->SetModeImage(aImage); | ||||||||||||
699 | else | ||||||||||||
700 | pTargetRadio->SetModeRadioImage(aImage); | ||||||||||||
701 | } | ||||||||||||
702 | switch (rImageInfo.m_nSize) | ||||||||||||
703 | { | ||||||||||||
704 | case 1: | ||||||||||||
705 | pTarget->SetSmallSymbol(); | ||||||||||||
706 | break; | ||||||||||||
707 | case 3: | ||||||||||||
708 | // large toolbar, make bigger than normal (4) | ||||||||||||
709 | pTarget->set_width_request(pTarget->GetOptimalSize().Width() * 1.5); | ||||||||||||
710 | pTarget->set_height_request(pTarget->GetOptimalSize().Height() * 1.5); | ||||||||||||
711 | break; | ||||||||||||
712 | case 4: | ||||||||||||
713 | break; | ||||||||||||
714 | default: | ||||||||||||
715 | SAL_WARN("vcl.builder", "unsupported image size " << rImageInfo.m_nSize)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unsupported image size " << rImageInfo.m_nSize) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "715" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "unsupported image size " << rImageInfo .m_nSize), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "unsupported image size " << rImageInfo.m_nSize; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "715" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unsupported image size " << rImageInfo.m_nSize ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "715" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "unsupported image size " << rImageInfo .m_nSize), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "unsupported image size " << rImageInfo.m_nSize; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "715" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
716 | break; | ||||||||||||
717 | } | ||||||||||||
718 | } | ||||||||||||
719 | } | ||||||||||||
720 | |||||||||||||
721 | //There may be duplicate use of an Image, so we used a set to collect and | ||||||||||||
722 | //now we can remove them from the tree after their final munge | ||||||||||||
723 | for (auto const& elem : aImagesToBeRemoved) | ||||||||||||
724 | { | ||||||||||||
725 | delete_by_name(elem.toUtf8()); | ||||||||||||
726 | } | ||||||||||||
727 | |||||||||||||
728 | //fill in any stock icons in surviving images | ||||||||||||
729 | for (auto const& elem : m_pParserState->m_aStockMap) | ||||||||||||
730 | { | ||||||||||||
731 | FixedImage *pImage = get<FixedImage>(elem.first); | ||||||||||||
732 | SAL_WARN_IF(!pImage, "vcl", "missing elements of image/stock: " << elem.first)do { if (true && (!pImage)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing elements of image/stock: " << elem.first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "732" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of image/stock: " << elem.first), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "missing elements of image/stock: " << elem.first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "732" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of image/stock: " << elem .first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "732" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of image/stock: " << elem.first), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "missing elements of image/stock: " << elem.first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "732" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
733 | if (!pImage) | ||||||||||||
734 | continue; | ||||||||||||
735 | |||||||||||||
736 | const stockinfo &rImageInfo = elem.second; | ||||||||||||
737 | if (rImageInfo.m_sStock == "gtk-missing-image") | ||||||||||||
738 | continue; | ||||||||||||
739 | |||||||||||||
740 | SymbolType eType = mapStockToSymbol(rImageInfo.m_sStock); | ||||||||||||
741 | SAL_WARN_IF(eType != SymbolType::IMAGE, "vcl", "unimplemented symbol type for images")do { if (true && (eType != SymbolType::IMAGE)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unimplemented symbol type for images") == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "741" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "unimplemented symbol type for images" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unimplemented symbol type for images"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "741" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unimplemented symbol type for images") == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "741" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "unimplemented symbol type for images" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unimplemented symbol type for images"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "741" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
742 | if (eType != SymbolType::IMAGE) | ||||||||||||
743 | continue; | ||||||||||||
744 | |||||||||||||
745 | Image const aImage(StockImage::Yes, | ||||||||||||
746 | mapStockToImageResource(rImageInfo.m_sStock)); | ||||||||||||
747 | pImage->SetImage(aImage); | ||||||||||||
748 | } | ||||||||||||
749 | |||||||||||||
750 | //Set button menus when everything has been imported | ||||||||||||
751 | for (auto const& elem : m_pParserState->m_aButtonMenuMaps) | ||||||||||||
752 | { | ||||||||||||
753 | MenuButton *pTarget = get<MenuButton>(elem.m_sID); | ||||||||||||
754 | PopupMenu *pMenu = get_menu(elem.m_sValue.toUtf8()); | ||||||||||||
755 | SAL_WARN_IF(!pTarget || !pMenu,do { if (true && (!pTarget || !pMenu)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing elements of button/menu" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "756" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of button/menu"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of button/menu"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "756" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of button/menu") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "756" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of button/menu"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of button/menu"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "756" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | ||||||||||||
756 | "vcl", "missing elements of button/menu")do { if (true && (!pTarget || !pMenu)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "missing elements of button/menu" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "756" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of button/menu"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of button/menu"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "756" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "missing elements of button/menu") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "756" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "missing elements of button/menu"), 0) ; } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "missing elements of button/menu"; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "756" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
757 | if (!pTarget || !pMenu) | ||||||||||||
758 | continue; | ||||||||||||
759 | pTarget->SetPopupMenu(pMenu); | ||||||||||||
760 | } | ||||||||||||
761 | |||||||||||||
762 | //Remove ScrollWindow parent widgets whose children in vcl implement scrolling | ||||||||||||
763 | //internally. | ||||||||||||
764 | for (auto const& elem : m_pParserState->m_aRedundantParentWidgets) | ||||||||||||
765 | { | ||||||||||||
766 | delete_by_window(elem.first); | ||||||||||||
767 | } | ||||||||||||
768 | |||||||||||||
769 | //fdo#67378 merge the label into the disclosure button | ||||||||||||
770 | for (auto const& elem : m_pParserState->m_aExpanderWidgets) | ||||||||||||
771 | { | ||||||||||||
772 | vcl::Window *pChild = elem->get_child(); | ||||||||||||
773 | vcl::Window* pLabel = elem->GetWindow(GetWindowType::LastChild); | ||||||||||||
774 | if (pLabel && pLabel != pChild && pLabel->GetType() == WindowType::FIXEDTEXT) | ||||||||||||
775 | { | ||||||||||||
776 | FixedText *pLabelWidget = static_cast<FixedText*>(pLabel); | ||||||||||||
777 | elem->set_label(pLabelWidget->GetText()); | ||||||||||||
778 | delete_by_window(pLabel); | ||||||||||||
779 | } | ||||||||||||
780 | } | ||||||||||||
781 | |||||||||||||
782 | // create message dialog message area now | ||||||||||||
783 | for (auto const& elem : m_pParserState->m_aMessageDialogs) | ||||||||||||
784 | elem->create_message_area(); | ||||||||||||
785 | |||||||||||||
786 | //drop maps, etc. that we don't need again | ||||||||||||
787 | m_pParserState.reset(); | ||||||||||||
788 | |||||||||||||
789 | SAL_WARN_IF(!m_sID.isEmpty() && (!m_bToplevelParentFound && !get_by_name(m_sID)), "vcl.builder",do { if (true && (!m_sID.isEmpty() && (!m_bToplevelParentFound && !get_by_name(m_sID)))) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "790" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "790" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "790" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "790" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | ||||||||||||
790 | "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile)do { if (true && (!m_sID.isEmpty() && (!m_bToplevelParentFound && !get_by_name(m_sID)))) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "790" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "790" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "790" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "790" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
791 | |||||||||||||
792 | #if defined SAL_LOG_WARN1 | ||||||||||||
793 | if (m_bToplevelParentFound && m_pParent->IsDialog()) | ||||||||||||
794 | { | ||||||||||||
795 | int nButtons = 0; | ||||||||||||
796 | bool bHasDefButton = false; | ||||||||||||
797 | for (auto const& child : m_aChildren) | ||||||||||||
798 | { | ||||||||||||
799 | if (isButtonType(child.m_pWindow->GetType())) | ||||||||||||
800 | { | ||||||||||||
801 | ++nButtons; | ||||||||||||
802 | if (child.m_pWindow->GetStyle() & WB_DEFBUTTON) | ||||||||||||
803 | { | ||||||||||||
804 | bHasDefButton = true; | ||||||||||||
805 | break; | ||||||||||||
806 | } | ||||||||||||
807 | } | ||||||||||||
808 | } | ||||||||||||
809 | SAL_WARN_IF(nButtons && !bHasDefButton, "vcl.builder", "No default button defined in " << sUIFile)do { if (true && (nButtons && !bHasDefButton) ) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "No default button defined in " << sUIFile) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "809" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "No default button defined in " << sUIFile), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "No default button defined in " << sUIFile; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "809" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "No default button defined in " << sUIFile) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "809" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "No default button defined in " << sUIFile), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "No default button defined in " << sUIFile; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "809" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
810 | } | ||||||||||||
811 | #endif | ||||||||||||
812 | |||||||||||||
813 | const bool bHideHelp = comphelper::LibreOfficeKit::isActive() && | ||||||||||||
814 | officecfg::Office::Common::Help::HelpRootURL::get().isEmpty(); | ||||||||||||
815 | if (bHideHelp) | ||||||||||||
816 | { | ||||||||||||
817 | if (vcl::Window *pHelpButton = get("help")) | ||||||||||||
818 | pHelpButton->Hide(); | ||||||||||||
819 | } | ||||||||||||
820 | } | ||||||||||||
821 | |||||||||||||
822 | VclBuilder::~VclBuilder() | ||||||||||||
823 | { | ||||||||||||
824 | disposeBuilder(); | ||||||||||||
825 | } | ||||||||||||
826 | |||||||||||||
827 | void VclBuilder::disposeBuilder() | ||||||||||||
828 | { | ||||||||||||
829 | for (std::vector<WinAndId>::reverse_iterator aI = m_aChildren.rbegin(), | ||||||||||||
830 | aEnd = m_aChildren.rend(); aI != aEnd; ++aI) | ||||||||||||
831 | { | ||||||||||||
832 | aI->m_pWindow.disposeAndClear(); | ||||||||||||
833 | } | ||||||||||||
834 | m_aChildren.clear(); | ||||||||||||
835 | |||||||||||||
836 | for (std::vector<MenuAndId>::reverse_iterator aI = m_aMenus.rbegin(), | ||||||||||||
837 | aEnd = m_aMenus.rend(); aI != aEnd; ++aI) | ||||||||||||
838 | { | ||||||||||||
839 | aI->m_pMenu.disposeAndClear(); | ||||||||||||
840 | } | ||||||||||||
841 | m_aMenus.clear(); | ||||||||||||
842 | m_pParent.clear(); | ||||||||||||
843 | } | ||||||||||||
844 | |||||||||||||
845 | namespace | ||||||||||||
846 | { | ||||||||||||
847 | bool extractHasFrame(VclBuilder::stringmap& rMap) | ||||||||||||
848 | { | ||||||||||||
849 | bool bHasFrame = true; | ||||||||||||
850 | VclBuilder::stringmap::iterator aFind = rMap.find("has-frame"); | ||||||||||||
851 | if (aFind != rMap.end()) | ||||||||||||
852 | { | ||||||||||||
853 | bHasFrame = toBool(aFind->second); | ||||||||||||
854 | rMap.erase(aFind); | ||||||||||||
855 | } | ||||||||||||
856 | return bHasFrame; | ||||||||||||
857 | } | ||||||||||||
858 | |||||||||||||
859 | bool extractDrawValue(VclBuilder::stringmap& rMap) | ||||||||||||
860 | { | ||||||||||||
861 | bool bDrawValue = true; | ||||||||||||
862 | VclBuilder::stringmap::iterator aFind = rMap.find("draw-value"); | ||||||||||||
863 | if (aFind != rMap.end()) | ||||||||||||
864 | { | ||||||||||||
865 | bDrawValue = toBool(aFind->second); | ||||||||||||
866 | rMap.erase(aFind); | ||||||||||||
867 | } | ||||||||||||
868 | return bDrawValue; | ||||||||||||
869 | } | ||||||||||||
870 | |||||||||||||
871 | OUString extractPopupMenu(VclBuilder::stringmap& rMap) | ||||||||||||
872 | { | ||||||||||||
873 | OUString sRet; | ||||||||||||
874 | VclBuilder::stringmap::iterator aFind = rMap.find("popup"); | ||||||||||||
875 | if (aFind != rMap.end()) | ||||||||||||
876 | { | ||||||||||||
877 | sRet = aFind->second; | ||||||||||||
878 | rMap.erase(aFind); | ||||||||||||
879 | } | ||||||||||||
880 | return sRet; | ||||||||||||
881 | } | ||||||||||||
882 | |||||||||||||
883 | OUString extractValuePos(VclBuilder::stringmap& rMap) | ||||||||||||
884 | { | ||||||||||||
885 | OUString sRet("top"); | ||||||||||||
886 | VclBuilder::stringmap::iterator aFind = rMap.find("value-pos"); | ||||||||||||
887 | if (aFind != rMap.end()) | ||||||||||||
888 | { | ||||||||||||
889 | sRet = aFind->second; | ||||||||||||
890 | rMap.erase(aFind); | ||||||||||||
891 | } | ||||||||||||
892 | return sRet; | ||||||||||||
893 | } | ||||||||||||
894 | |||||||||||||
895 | OUString extractTypeHint(VclBuilder::stringmap &rMap) | ||||||||||||
896 | { | ||||||||||||
897 | OUString sRet("normal"); | ||||||||||||
898 | VclBuilder::stringmap::iterator aFind = rMap.find("type-hint"); | ||||||||||||
899 | if (aFind != rMap.end()) | ||||||||||||
900 | { | ||||||||||||
901 | sRet = aFind->second; | ||||||||||||
902 | rMap.erase(aFind); | ||||||||||||
903 | } | ||||||||||||
904 | return sRet; | ||||||||||||
905 | } | ||||||||||||
906 | |||||||||||||
907 | bool extractResizable(VclBuilder::stringmap &rMap) | ||||||||||||
908 | { | ||||||||||||
909 | bool bResizable = true; | ||||||||||||
910 | VclBuilder::stringmap::iterator aFind = rMap.find("resizable"); | ||||||||||||
911 | if (aFind != rMap.end()) | ||||||||||||
912 | { | ||||||||||||
913 | bResizable = toBool(aFind->second); | ||||||||||||
914 | rMap.erase(aFind); | ||||||||||||
915 | } | ||||||||||||
916 | return bResizable; | ||||||||||||
917 | } | ||||||||||||
918 | |||||||||||||
919 | #if HAVE_FEATURE_DESKTOP1 | ||||||||||||
920 | bool extractModal(VclBuilder::stringmap &rMap) | ||||||||||||
921 | { | ||||||||||||
922 | bool bModal = false; | ||||||||||||
923 | VclBuilder::stringmap::iterator aFind = rMap.find("modal"); | ||||||||||||
924 | if (aFind != rMap.end()) | ||||||||||||
925 | { | ||||||||||||
926 | bModal = toBool(aFind->second); | ||||||||||||
927 | rMap.erase(aFind); | ||||||||||||
928 | } | ||||||||||||
929 | return bModal; | ||||||||||||
930 | } | ||||||||||||
931 | #endif | ||||||||||||
932 | |||||||||||||
933 | bool extractDecorated(VclBuilder::stringmap &rMap) | ||||||||||||
934 | { | ||||||||||||
935 | bool bDecorated = true; | ||||||||||||
936 | VclBuilder::stringmap::iterator aFind = rMap.find("decorated"); | ||||||||||||
937 | if (aFind != rMap.end()) | ||||||||||||
938 | { | ||||||||||||
939 | bDecorated = toBool(aFind->second); | ||||||||||||
940 | rMap.erase(aFind); | ||||||||||||
941 | } | ||||||||||||
942 | return bDecorated; | ||||||||||||
943 | } | ||||||||||||
944 | |||||||||||||
945 | bool extractCloseable(VclBuilder::stringmap &rMap) | ||||||||||||
946 | { | ||||||||||||
947 | bool bCloseable = true; | ||||||||||||
948 | VclBuilder::stringmap::iterator aFind = rMap.find("deletable"); | ||||||||||||
949 | if (aFind != rMap.end()) | ||||||||||||
950 | { | ||||||||||||
951 | bCloseable = toBool(aFind->second); | ||||||||||||
952 | rMap.erase(aFind); | ||||||||||||
953 | } | ||||||||||||
954 | return bCloseable; | ||||||||||||
955 | } | ||||||||||||
956 | |||||||||||||
957 | bool extractEntry(VclBuilder::stringmap &rMap) | ||||||||||||
958 | { | ||||||||||||
959 | bool bHasEntry = false; | ||||||||||||
960 | VclBuilder::stringmap::iterator aFind = rMap.find("has-entry"); | ||||||||||||
961 | if (aFind != rMap.end()) | ||||||||||||
962 | { | ||||||||||||
963 | bHasEntry = toBool(aFind->second); | ||||||||||||
964 | rMap.erase(aFind); | ||||||||||||
965 | } | ||||||||||||
966 | return bHasEntry; | ||||||||||||
967 | } | ||||||||||||
968 | |||||||||||||
969 | bool extractOrientation(VclBuilder::stringmap &rMap) | ||||||||||||
970 | { | ||||||||||||
971 | bool bVertical = false; | ||||||||||||
972 | VclBuilder::stringmap::iterator aFind = rMap.find("orientation"); | ||||||||||||
973 | if (aFind != rMap.end()) | ||||||||||||
974 | { | ||||||||||||
975 | bVertical = aFind->second.equalsIgnoreAsciiCase("vertical"); | ||||||||||||
976 | rMap.erase(aFind); | ||||||||||||
977 | } | ||||||||||||
978 | return bVertical; | ||||||||||||
979 | } | ||||||||||||
980 | |||||||||||||
981 | bool extractVerticalTabPos(VclBuilder::stringmap &rMap) | ||||||||||||
982 | { | ||||||||||||
983 | bool bVertical = false; | ||||||||||||
984 | VclBuilder::stringmap::iterator aFind = rMap.find("tab-pos"); | ||||||||||||
985 | if (aFind != rMap.end()) | ||||||||||||
986 | { | ||||||||||||
987 | bVertical = aFind->second.equalsIgnoreAsciiCase("left") || | ||||||||||||
988 | aFind->second.equalsIgnoreAsciiCase("right"); | ||||||||||||
989 | rMap.erase(aFind); | ||||||||||||
990 | } | ||||||||||||
991 | return bVertical; | ||||||||||||
992 | } | ||||||||||||
993 | |||||||||||||
994 | bool extractInconsistent(VclBuilder::stringmap &rMap) | ||||||||||||
995 | { | ||||||||||||
996 | bool bInconsistent = false; | ||||||||||||
997 | VclBuilder::stringmap::iterator aFind = rMap.find("inconsistent"); | ||||||||||||
998 | if (aFind != rMap.end()) | ||||||||||||
999 | { | ||||||||||||
1000 | bInconsistent = toBool(aFind->second); | ||||||||||||
1001 | rMap.erase(aFind); | ||||||||||||
1002 | } | ||||||||||||
1003 | return bInconsistent; | ||||||||||||
1004 | } | ||||||||||||
1005 | |||||||||||||
1006 | OUString extractIconName(VclBuilder::stringmap &rMap) | ||||||||||||
1007 | { | ||||||||||||
1008 | OUString sIconName; | ||||||||||||
1009 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("icon-name")); | ||||||||||||
1010 | if (aFind != rMap.end()) | ||||||||||||
1011 | { | ||||||||||||
1012 | sIconName = aFind->second; | ||||||||||||
1013 | rMap.erase(aFind); | ||||||||||||
1014 | } | ||||||||||||
1015 | return sIconName; | ||||||||||||
1016 | } | ||||||||||||
1017 | |||||||||||||
1018 | OUString extractStockId(VclBuilder::stringmap &rMap) | ||||||||||||
1019 | { | ||||||||||||
1020 | OUString sIconName; | ||||||||||||
1021 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("stock-id")); | ||||||||||||
1022 | if (aFind != rMap.end()) | ||||||||||||
1023 | { | ||||||||||||
1024 | sIconName = aFind->second; | ||||||||||||
1025 | rMap.erase(aFind); | ||||||||||||
1026 | } | ||||||||||||
1027 | return sIconName; | ||||||||||||
1028 | } | ||||||||||||
1029 | |||||||||||||
1030 | OUString getStockText(const OUString &rType) | ||||||||||||
1031 | { | ||||||||||||
1032 | if (rType == "gtk-ok") | ||||||||||||
1033 | return VclResId(SV_BUTTONTEXT_OKreinterpret_cast<char const *>("SV_BUTTONTEXT_OK" "\004" u8"~OK")); | ||||||||||||
1034 | else if (rType == "gtk-cancel") | ||||||||||||
1035 | return VclResId(SV_BUTTONTEXT_CANCELreinterpret_cast<char const *>("SV_BUTTONTEXT_CANCEL" "\004" u8"~Cancel")); | ||||||||||||
1036 | else if (rType == "gtk-help") | ||||||||||||
1037 | return VclResId(SV_BUTTONTEXT_HELPreinterpret_cast<char const *>("SV_BUTTONTEXT_HELP" "\004" u8"~Help")); | ||||||||||||
1038 | else if (rType == "gtk-close") | ||||||||||||
1039 | return VclResId(SV_BUTTONTEXT_CLOSEreinterpret_cast<char const *>("SV_BUTTONTEXT_CLOSE" "\004" u8"~Close")); | ||||||||||||
1040 | else if (rType == "gtk-revert-to-saved") | ||||||||||||
1041 | return VclResId(SV_BUTTONTEXT_RESETreinterpret_cast<char const *>("SV_BUTTONTEXT_RESET" "\004" u8"R~eset")); | ||||||||||||
1042 | else if (rType == "gtk-add") | ||||||||||||
1043 | return VclResId(SV_BUTTONTEXT_ADDreinterpret_cast<char const *>("SV_BUTTONTEXT_ADD" "\004" u8"~Add")); | ||||||||||||
1044 | else if (rType == "gtk-delete") | ||||||||||||
1045 | return VclResId(SV_BUTTONTEXT_DELETEreinterpret_cast<char const *>("SV_BUTTONTEXT_DELETE" "\004" u8"~Delete")); | ||||||||||||
1046 | else if (rType == "gtk-remove") | ||||||||||||
1047 | return VclResId(SV_BUTTONTEXT_REMOVEreinterpret_cast<char const *>("SV_BUTTONTEXT_REMOVE" "\004" u8"~Remove")); | ||||||||||||
1048 | else if (rType == "gtk-new") | ||||||||||||
1049 | return VclResId(SV_BUTTONTEXT_NEWreinterpret_cast<char const *>("SV_BUTTONTEXT_NEW" "\004" u8"~New")); | ||||||||||||
1050 | else if (rType == "gtk-edit") | ||||||||||||
1051 | return VclResId(SV_BUTTONTEXT_EDITreinterpret_cast<char const *>("SV_BUTTONTEXT_EDIT" "\004" u8"~Edit")); | ||||||||||||
1052 | else if (rType == "gtk-apply") | ||||||||||||
1053 | return VclResId(SV_BUTTONTEXT_APPLYreinterpret_cast<char const *>("SV_BUTTONTEXT_APPLY" "\004" u8"~Apply")); | ||||||||||||
1054 | else if (rType == "gtk-save") | ||||||||||||
1055 | return VclResId(SV_BUTTONTEXT_SAVEreinterpret_cast<char const *>("SV_BUTTONTEXT_SAVE" "\004" u8"~Save")); | ||||||||||||
1056 | else if (rType == "gtk-open") | ||||||||||||
1057 | return VclResId(SV_BUTTONTEXT_OPENreinterpret_cast<char const *>("SV_BUTTONTEXT_OPEN" "\004" u8"~Open")); | ||||||||||||
1058 | else if (rType == "gtk-undo") | ||||||||||||
1059 | return VclResId(SV_BUTTONTEXT_UNDOreinterpret_cast<char const *>("SV_BUTTONTEXT_UNDO" "\004" u8"~Undo")); | ||||||||||||
1060 | else if (rType == "gtk-paste") | ||||||||||||
1061 | return VclResId(SV_BUTTONTEXT_PASTEreinterpret_cast<char const *>("SV_BUTTONTEXT_PASTE" "\004" u8"~Paste")); | ||||||||||||
1062 | else if (rType == "gtk-media-next") | ||||||||||||
1063 | return VclResId(SV_BUTTONTEXT_NEXTreinterpret_cast<char const *>("SV_BUTTONTEXT_NEXT" "\004" u8"~Next")); | ||||||||||||
1064 | else if (rType == "gtk-media-previous") | ||||||||||||
1065 | return VclResId(SV_BUTTONTEXT_PREVreinterpret_cast<char const *>("SV_BUTTONTEXT_PREV" "\004" u8"~Previous")); | ||||||||||||
1066 | else if (rType == "gtk-go-up") | ||||||||||||
1067 | return VclResId(SV_BUTTONTEXT_GO_UPreinterpret_cast<char const *>("SV_BUTTONTEXT_GO_UP" "\004" u8"~Up")); | ||||||||||||
1068 | else if (rType == "gtk-go-down") | ||||||||||||
1069 | return VclResId(SV_BUTTONTEXT_GO_DOWNreinterpret_cast<char const *>("SV_BUTTONTEXT_GO_DOWN" "\004" u8"Do~wn")); | ||||||||||||
1070 | else if (rType == "gtk-clear") | ||||||||||||
1071 | return VclResId(SV_BUTTONTEXT_CLEARreinterpret_cast<char const *>("SV_BUTTONTEXT_CLEAR" "\004" u8"~Clear")); | ||||||||||||
1072 | else if (rType == "gtk-media-play") | ||||||||||||
1073 | return VclResId(SV_BUTTONTEXT_PLAYreinterpret_cast<char const *>("SV_BUTTONTEXT_PLAY" "\004" u8"~Play")); | ||||||||||||
1074 | else if (rType == "gtk-find") | ||||||||||||
1075 | return VclResId(SV_BUTTONTEXT_FINDreinterpret_cast<char const *>("SV_BUTTONTEXT_FIND" "\004" u8"~Find")); | ||||||||||||
1076 | else if (rType == "gtk-stop") | ||||||||||||
1077 | return VclResId(SV_BUTTONTEXT_STOPreinterpret_cast<char const *>("SV_BUTTONTEXT_STOP" "\004" u8"~Stop")); | ||||||||||||
1078 | else if (rType == "gtk-connect") | ||||||||||||
1079 | return VclResId(SV_BUTTONTEXT_CONNECTreinterpret_cast<char const *>("SV_BUTTONTEXT_CONNECT" "\004" u8"C~onnect")); | ||||||||||||
1080 | else if (rType == "gtk-yes") | ||||||||||||
1081 | return VclResId(SV_BUTTONTEXT_YESreinterpret_cast<char const *>("SV_BUTTONTEXT_YES" "\004" u8"~Yes")); | ||||||||||||
1082 | else if (rType == "gtk-no") | ||||||||||||
1083 | return VclResId(SV_BUTTONTEXT_NOreinterpret_cast<char const *>("SV_BUTTONTEXT_NO" "\004" u8"~No")); | ||||||||||||
1084 | SAL_WARN("vcl.builder", "unknown stock type: " << rType)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unknown stock type: " << rType) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1084" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unknown stock type: " << rType ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unknown stock type: " << rType; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1084" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unknown stock type: " << rType) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1084" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unknown stock type: " << rType ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unknown stock type: " << rType; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1084" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
1085 | return OUString(); | ||||||||||||
1086 | } | ||||||||||||
1087 | |||||||||||||
1088 | bool extractStock(VclBuilder::stringmap &rMap) | ||||||||||||
1089 | { | ||||||||||||
1090 | bool bIsStock = false; | ||||||||||||
1091 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("use-stock")); | ||||||||||||
1092 | if (aFind != rMap.end()) | ||||||||||||
1093 | { | ||||||||||||
1094 | bIsStock = toBool(aFind->second); | ||||||||||||
1095 | rMap.erase(aFind); | ||||||||||||
1096 | } | ||||||||||||
1097 | return bIsStock; | ||||||||||||
1098 | } | ||||||||||||
1099 | |||||||||||||
1100 | WinBits extractRelief(VclBuilder::stringmap &rMap) | ||||||||||||
1101 | { | ||||||||||||
1102 | WinBits nBits = WB_3DLOOK; | ||||||||||||
1103 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("relief")); | ||||||||||||
1104 | if (aFind != rMap.end()) | ||||||||||||
1105 | { | ||||||||||||
1106 | if (aFind->second == "half") | ||||||||||||
1107 | nBits = WB_FLATBUTTON | WB_BEVELBUTTON; | ||||||||||||
1108 | else if (aFind->second == "none") | ||||||||||||
1109 | nBits = WB_FLATBUTTON; | ||||||||||||
1110 | rMap.erase(aFind); | ||||||||||||
1111 | } | ||||||||||||
1112 | return nBits; | ||||||||||||
1113 | } | ||||||||||||
1114 | |||||||||||||
1115 | OUString extractLabel(VclBuilder::stringmap &rMap) | ||||||||||||
1116 | { | ||||||||||||
1117 | OUString sType; | ||||||||||||
1118 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("label")); | ||||||||||||
1119 | if (aFind != rMap.end()) | ||||||||||||
1120 | { | ||||||||||||
1121 | sType = aFind->second; | ||||||||||||
1122 | rMap.erase(aFind); | ||||||||||||
1123 | } | ||||||||||||
1124 | return sType; | ||||||||||||
1125 | } | ||||||||||||
1126 | |||||||||||||
1127 | OUString extractActionName(VclBuilder::stringmap &rMap) | ||||||||||||
1128 | { | ||||||||||||
1129 | OUString sActionName; | ||||||||||||
1130 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("action-name")); | ||||||||||||
1131 | if (aFind != rMap.end()) | ||||||||||||
1132 | { | ||||||||||||
1133 | sActionName = aFind->second; | ||||||||||||
1134 | rMap.erase(aFind); | ||||||||||||
1135 | } | ||||||||||||
1136 | return sActionName; | ||||||||||||
1137 | } | ||||||||||||
1138 | |||||||||||||
1139 | bool extractVisible(VclBuilder::stringmap &rMap) | ||||||||||||
1140 | { | ||||||||||||
1141 | bool bRet = false; | ||||||||||||
1142 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("visible")); | ||||||||||||
1143 | if (aFind != rMap.end()) | ||||||||||||
1144 | { | ||||||||||||
1145 | bRet = toBool(aFind->second); | ||||||||||||
1146 | rMap.erase(aFind); | ||||||||||||
1147 | } | ||||||||||||
1148 | return bRet; | ||||||||||||
1149 | } | ||||||||||||
1150 | |||||||||||||
1151 | Size extractSizeRequest(VclBuilder::stringmap &rMap) | ||||||||||||
1152 | { | ||||||||||||
1153 | OUString sWidthRequest("0"); | ||||||||||||
1154 | OUString sHeightRequest("0"); | ||||||||||||
1155 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("width-request")); | ||||||||||||
1156 | if (aFind != rMap.end()) | ||||||||||||
1157 | { | ||||||||||||
1158 | sWidthRequest = aFind->second; | ||||||||||||
1159 | rMap.erase(aFind); | ||||||||||||
1160 | } | ||||||||||||
1161 | aFind = rMap.find("height-request"); | ||||||||||||
1162 | if (aFind != rMap.end()) | ||||||||||||
1163 | { | ||||||||||||
1164 | sHeightRequest = aFind->second; | ||||||||||||
1165 | rMap.erase(aFind); | ||||||||||||
1166 | } | ||||||||||||
1167 | return Size(sWidthRequest.toInt32(), sHeightRequest.toInt32()); | ||||||||||||
1168 | } | ||||||||||||
1169 | |||||||||||||
1170 | OUString extractTooltipText(VclBuilder::stringmap &rMap) | ||||||||||||
1171 | { | ||||||||||||
1172 | OUString sTooltipText; | ||||||||||||
1173 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("tooltip-text")); | ||||||||||||
1174 | if (aFind == rMap.end()) | ||||||||||||
1175 | aFind = rMap.find(OString("tooltip-markup")); | ||||||||||||
1176 | if (aFind != rMap.end()) | ||||||||||||
1177 | { | ||||||||||||
1178 | sTooltipText = aFind->second; | ||||||||||||
1179 | rMap.erase(aFind); | ||||||||||||
1180 | } | ||||||||||||
1181 | return sTooltipText; | ||||||||||||
1182 | } | ||||||||||||
1183 | |||||||||||||
1184 | float extractAlignment(VclBuilder::stringmap &rMap) | ||||||||||||
1185 | { | ||||||||||||
1186 | float f = 0.0; | ||||||||||||
1187 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("alignment")); | ||||||||||||
1188 | if (aFind != rMap.end()) | ||||||||||||
1189 | { | ||||||||||||
1190 | f = aFind->second.toFloat(); | ||||||||||||
1191 | rMap.erase(aFind); | ||||||||||||
1192 | } | ||||||||||||
1193 | return f; | ||||||||||||
1194 | } | ||||||||||||
1195 | |||||||||||||
1196 | OUString extractTitle(VclBuilder::stringmap &rMap) | ||||||||||||
1197 | { | ||||||||||||
1198 | OUString sTitle; | ||||||||||||
1199 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("title")); | ||||||||||||
1200 | if (aFind != rMap.end()) | ||||||||||||
1201 | { | ||||||||||||
1202 | sTitle = aFind->second; | ||||||||||||
1203 | rMap.erase(aFind); | ||||||||||||
1204 | } | ||||||||||||
1205 | return sTitle; | ||||||||||||
1206 | } | ||||||||||||
1207 | |||||||||||||
1208 | bool extractHeadersVisible(VclBuilder::stringmap &rMap) | ||||||||||||
1209 | { | ||||||||||||
1210 | bool bHeadersVisible = true; | ||||||||||||
1211 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("headers-visible")); | ||||||||||||
1212 | if (aFind != rMap.end()) | ||||||||||||
1213 | { | ||||||||||||
1214 | bHeadersVisible = toBool(aFind->second); | ||||||||||||
1215 | rMap.erase(aFind); | ||||||||||||
1216 | } | ||||||||||||
1217 | return bHeadersVisible; | ||||||||||||
1218 | } | ||||||||||||
1219 | |||||||||||||
1220 | bool extractSortIndicator(VclBuilder::stringmap &rMap) | ||||||||||||
1221 | { | ||||||||||||
1222 | bool bSortIndicator = false; | ||||||||||||
1223 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("sort-indicator")); | ||||||||||||
1224 | if (aFind != rMap.end()) | ||||||||||||
1225 | { | ||||||||||||
1226 | bSortIndicator = toBool(aFind->second); | ||||||||||||
1227 | rMap.erase(aFind); | ||||||||||||
1228 | } | ||||||||||||
1229 | return bSortIndicator; | ||||||||||||
1230 | } | ||||||||||||
1231 | |||||||||||||
1232 | bool extractClickable(VclBuilder::stringmap &rMap) | ||||||||||||
1233 | { | ||||||||||||
1234 | bool bClickable = false; | ||||||||||||
1235 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("clickable")); | ||||||||||||
1236 | if (aFind != rMap.end()) | ||||||||||||
1237 | { | ||||||||||||
1238 | bClickable = toBool(aFind->second); | ||||||||||||
1239 | rMap.erase(aFind); | ||||||||||||
1240 | } | ||||||||||||
1241 | return bClickable; | ||||||||||||
1242 | } | ||||||||||||
1243 | |||||||||||||
1244 | void setupFromActionName(Button *pButton, VclBuilder::stringmap &rMap, const css::uno::Reference<css::frame::XFrame>& rFrame) | ||||||||||||
1245 | { | ||||||||||||
1246 | if (!rFrame.is()) | ||||||||||||
1247 | return; | ||||||||||||
1248 | |||||||||||||
1249 | OUString aCommand(extractActionName(rMap)); | ||||||||||||
1250 | if (aCommand.isEmpty()) | ||||||||||||
1251 | return; | ||||||||||||
1252 | |||||||||||||
1253 | OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(rFrame)); | ||||||||||||
1254 | auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aCommand, aModuleName); | ||||||||||||
1255 | OUString aLabel(vcl::CommandInfoProvider::GetLabelForCommand(aProperties)); | ||||||||||||
1256 | if (!aLabel.isEmpty()) | ||||||||||||
1257 | pButton->SetText(aLabel); | ||||||||||||
1258 | |||||||||||||
1259 | OUString aTooltip(vcl::CommandInfoProvider::GetTooltipForCommand(aCommand, aProperties, rFrame)); | ||||||||||||
1260 | if (!aTooltip.isEmpty()) | ||||||||||||
1261 | pButton->SetQuickHelpText(aTooltip); | ||||||||||||
1262 | |||||||||||||
1263 | Image aImage(vcl::CommandInfoProvider::GetImageForCommand(aCommand, rFrame)); | ||||||||||||
1264 | pButton->SetModeImage(aImage); | ||||||||||||
1265 | |||||||||||||
1266 | pButton->SetCommandHandler(aCommand); | ||||||||||||
1267 | } | ||||||||||||
1268 | |||||||||||||
1269 | VclPtr<Button> extractStockAndBuildPushButton(vcl::Window *pParent, VclBuilder::stringmap &rMap, bool bToggle, bool bLegacy) | ||||||||||||
1270 | { | ||||||||||||
1271 | WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER; | ||||||||||||
1272 | if (bToggle) | ||||||||||||
1273 | nBits |= WB_TOGGLE; | ||||||||||||
1274 | |||||||||||||
1275 | nBits |= extractRelief(rMap); | ||||||||||||
1276 | |||||||||||||
1277 | VclPtr<Button> xWindow; | ||||||||||||
1278 | |||||||||||||
1279 | if (extractStock(rMap)) | ||||||||||||
1280 | { | ||||||||||||
1281 | OUString sType = extractLabel(rMap); | ||||||||||||
1282 | if (bLegacy) | ||||||||||||
1283 | { | ||||||||||||
1284 | if (sType == "gtk-ok") | ||||||||||||
1285 | xWindow = VclPtr<OKButton>::Create(pParent, nBits); | ||||||||||||
1286 | else if (sType == "gtk-cancel") | ||||||||||||
1287 | xWindow = VclPtr<CancelButton>::Create(pParent, nBits); | ||||||||||||
1288 | else if (sType == "gtk-close") | ||||||||||||
1289 | xWindow = VclPtr<CloseButton>::Create(pParent, nBits); | ||||||||||||
1290 | else if (sType == "gtk-help") | ||||||||||||
1291 | xWindow = VclPtr<HelpButton>::Create(pParent, nBits); | ||||||||||||
1292 | } | ||||||||||||
1293 | if (!xWindow) | ||||||||||||
1294 | { | ||||||||||||
1295 | xWindow = VclPtr<PushButton>::Create(pParent, nBits); | ||||||||||||
1296 | xWindow->SetText(getStockText(sType)); | ||||||||||||
1297 | } | ||||||||||||
1298 | } | ||||||||||||
1299 | |||||||||||||
1300 | if (!xWindow) | ||||||||||||
1301 | xWindow = VclPtr<PushButton>::Create(pParent, nBits); | ||||||||||||
1302 | return xWindow; | ||||||||||||
1303 | } | ||||||||||||
1304 | |||||||||||||
1305 | VclPtr<MenuButton> extractStockAndBuildMenuButton(vcl::Window *pParent, VclBuilder::stringmap &rMap) | ||||||||||||
1306 | { | ||||||||||||
1307 | WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK; | ||||||||||||
1308 | |||||||||||||
1309 | nBits |= extractRelief(rMap); | ||||||||||||
1310 | |||||||||||||
1311 | VclPtr<MenuButton> xWindow = VclPtr<MenuButton>::Create(pParent, nBits); | ||||||||||||
1312 | |||||||||||||
1313 | if (extractStock(rMap)) | ||||||||||||
1314 | { | ||||||||||||
1315 | xWindow->SetText(getStockText(extractLabel(rMap))); | ||||||||||||
1316 | } | ||||||||||||
1317 | |||||||||||||
1318 | return xWindow; | ||||||||||||
1319 | } | ||||||||||||
1320 | |||||||||||||
1321 | VclPtr<Button> extractStockAndBuildMenuToggleButton(vcl::Window *pParent, VclBuilder::stringmap &rMap) | ||||||||||||
1322 | { | ||||||||||||
1323 | WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK; | ||||||||||||
1324 | |||||||||||||
1325 | nBits |= extractRelief(rMap); | ||||||||||||
1326 | |||||||||||||
1327 | VclPtr<Button> xWindow = VclPtr<MenuToggleButton>::Create(pParent, nBits); | ||||||||||||
1328 | |||||||||||||
1329 | if (extractStock(rMap)) | ||||||||||||
1330 | { | ||||||||||||
1331 | xWindow->SetText(getStockText(extractLabel(rMap))); | ||||||||||||
1332 | } | ||||||||||||
1333 | |||||||||||||
1334 | return xWindow; | ||||||||||||
1335 | } | ||||||||||||
1336 | |||||||||||||
1337 | WinBits extractDeferredBits(VclBuilder::stringmap &rMap) | ||||||||||||
1338 | { | ||||||||||||
1339 | WinBits nBits = WB_3DLOOK|WB_HIDE; | ||||||||||||
1340 | if (extractResizable(rMap)) | ||||||||||||
1341 | nBits |= WB_SIZEABLE; | ||||||||||||
1342 | if (extractCloseable(rMap)) | ||||||||||||
1343 | nBits |= WB_CLOSEABLE; | ||||||||||||
1344 | if (!extractDecorated(rMap)) | ||||||||||||
1345 | nBits |= WB_OWNERDRAWDECORATION; | ||||||||||||
1346 | OUString sType(extractTypeHint(rMap)); | ||||||||||||
1347 | if (sType == "utility") | ||||||||||||
1348 | nBits |= WB_SYSTEMWINDOW | WB_DIALOGCONTROL | WB_MOVEABLE; | ||||||||||||
1349 | else if (sType == "popup-menu") | ||||||||||||
1350 | nBits |= WB_SYSTEMWINDOW | WB_DIALOGCONTROL | WB_POPUP; | ||||||||||||
1351 | else if (sType == "dock") | ||||||||||||
1352 | nBits |= WB_DOCKABLE | WB_MOVEABLE; | ||||||||||||
1353 | else | ||||||||||||
1354 | nBits |= WB_MOVEABLE; | ||||||||||||
1355 | return nBits; | ||||||||||||
1356 | } | ||||||||||||
1357 | } | ||||||||||||
1358 | |||||||||||||
1359 | void VclBuilder::extractGroup(const OString &id, stringmap &rMap) | ||||||||||||
1360 | { | ||||||||||||
1361 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("group")); | ||||||||||||
1362 | if (aFind != rMap.end()) | ||||||||||||
1363 | { | ||||||||||||
1364 | OUString sID = aFind->second; | ||||||||||||
1365 | sal_Int32 nDelim = sID.indexOf(':'); | ||||||||||||
1366 | if (nDelim != -1) | ||||||||||||
1367 | sID = sID.copy(0, nDelim); | ||||||||||||
1368 | m_pParserState->m_aGroupMaps.emplace_back(id, sID.toUtf8()); | ||||||||||||
1369 | rMap.erase(aFind); | ||||||||||||
1370 | } | ||||||||||||
1371 | } | ||||||||||||
1372 | |||||||||||||
1373 | void VclBuilder::connectNumericFormatterAdjustment(const OString &id, const OUString &rAdjustment) | ||||||||||||
1374 | { | ||||||||||||
1375 | if (!rAdjustment.isEmpty()) | ||||||||||||
1376 | m_pParserState->m_aNumericFormatterAdjustmentMaps.emplace_back(id, rAdjustment); | ||||||||||||
1377 | } | ||||||||||||
1378 | |||||||||||||
1379 | void VclBuilder::connectFormattedFormatterAdjustment(const OString &id, const OUString &rAdjustment) | ||||||||||||
1380 | { | ||||||||||||
1381 | if (!rAdjustment.isEmpty()) | ||||||||||||
1382 | m_pParserState->m_aFormattedFormatterAdjustmentMaps.emplace_back(id, rAdjustment); | ||||||||||||
1383 | } | ||||||||||||
1384 | |||||||||||||
1385 | bool VclBuilder::extractAdjustmentToMap(const OString& id, VclBuilder::stringmap& rMap, std::vector<WidgetAdjustmentMap>& rAdjustmentMap) | ||||||||||||
1386 | { | ||||||||||||
1387 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("adjustment")); | ||||||||||||
1388 | if (aFind != rMap.end()) | ||||||||||||
1389 | { | ||||||||||||
1390 | rAdjustmentMap.emplace_back(id, aFind->second); | ||||||||||||
1391 | rMap.erase(aFind); | ||||||||||||
1392 | return true; | ||||||||||||
1393 | } | ||||||||||||
1394 | return false; | ||||||||||||
1395 | } | ||||||||||||
1396 | |||||||||||||
1397 | namespace | ||||||||||||
1398 | { | ||||||||||||
1399 | sal_Int32 extractActive(VclBuilder::stringmap &rMap) | ||||||||||||
1400 | { | ||||||||||||
1401 | sal_Int32 nActiveId = 0; | ||||||||||||
1402 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("active")); | ||||||||||||
1403 | if (aFind != rMap.end()) | ||||||||||||
1404 | { | ||||||||||||
1405 | nActiveId = aFind->second.toInt32(); | ||||||||||||
1406 | rMap.erase(aFind); | ||||||||||||
1407 | } | ||||||||||||
1408 | return nActiveId; | ||||||||||||
1409 | } | ||||||||||||
1410 | |||||||||||||
1411 | bool extractSelectable(VclBuilder::stringmap &rMap) | ||||||||||||
1412 | { | ||||||||||||
1413 | bool bSelectable = false; | ||||||||||||
1414 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("selectable")); | ||||||||||||
1415 | if (aFind != rMap.end()) | ||||||||||||
1416 | { | ||||||||||||
1417 | bSelectable = toBool(aFind->second); | ||||||||||||
1418 | rMap.erase(aFind); | ||||||||||||
1419 | } | ||||||||||||
1420 | return bSelectable; | ||||||||||||
1421 | } | ||||||||||||
1422 | |||||||||||||
1423 | OUString extractAdjustment(VclBuilder::stringmap &rMap) | ||||||||||||
1424 | { | ||||||||||||
1425 | OUString sAdjustment; | ||||||||||||
1426 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("adjustment")); | ||||||||||||
1427 | if (aFind != rMap.end()) | ||||||||||||
1428 | { | ||||||||||||
1429 | sAdjustment= aFind->second; | ||||||||||||
1430 | rMap.erase(aFind); | ||||||||||||
1431 | return sAdjustment; | ||||||||||||
1432 | } | ||||||||||||
1433 | return sAdjustment; | ||||||||||||
1434 | } | ||||||||||||
1435 | |||||||||||||
1436 | bool extractDrawIndicator(VclBuilder::stringmap &rMap) | ||||||||||||
1437 | { | ||||||||||||
1438 | bool bDrawIndicator = false; | ||||||||||||
1439 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("draw-indicator")); | ||||||||||||
1440 | if (aFind != rMap.end()) | ||||||||||||
1441 | { | ||||||||||||
1442 | bDrawIndicator = toBool(aFind->second); | ||||||||||||
1443 | rMap.erase(aFind); | ||||||||||||
1444 | } | ||||||||||||
1445 | return bDrawIndicator; | ||||||||||||
1446 | } | ||||||||||||
1447 | } | ||||||||||||
1448 | |||||||||||||
1449 | void VclBuilder::extractModel(const OString &id, stringmap &rMap) | ||||||||||||
1450 | { | ||||||||||||
1451 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("model")); | ||||||||||||
1452 | if (aFind != rMap.end()) | ||||||||||||
1453 | { | ||||||||||||
1454 | m_pParserState->m_aModelMaps.emplace_back(id, aFind->second, | ||||||||||||
1455 | extractActive(rMap)); | ||||||||||||
1456 | rMap.erase(aFind); | ||||||||||||
1457 | } | ||||||||||||
1458 | } | ||||||||||||
1459 | |||||||||||||
1460 | void VclBuilder::extractBuffer(const OString &id, stringmap &rMap) | ||||||||||||
1461 | { | ||||||||||||
1462 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("buffer")); | ||||||||||||
1463 | if (aFind != rMap.end()) | ||||||||||||
1464 | { | ||||||||||||
1465 | m_pParserState->m_aTextBufferMaps.emplace_back(id, aFind->second); | ||||||||||||
1466 | rMap.erase(aFind); | ||||||||||||
1467 | } | ||||||||||||
1468 | } | ||||||||||||
1469 | |||||||||||||
1470 | void VclBuilder::extractStock(const OString &id, stringmap &rMap) | ||||||||||||
1471 | { | ||||||||||||
1472 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("stock")); | ||||||||||||
1473 | if (aFind == rMap.end()) | ||||||||||||
1474 | return; | ||||||||||||
1475 | |||||||||||||
1476 | stockinfo aInfo; | ||||||||||||
1477 | aInfo.m_sStock = aFind->second; | ||||||||||||
1478 | rMap.erase(aFind); | ||||||||||||
1479 | aFind = rMap.find(OString("icon-size")); | ||||||||||||
1480 | if (aFind != rMap.end()) | ||||||||||||
1481 | { | ||||||||||||
1482 | aInfo.m_nSize = aFind->second.toInt32(); | ||||||||||||
1483 | rMap.erase(aFind); | ||||||||||||
1484 | } | ||||||||||||
1485 | m_pParserState->m_aStockMap[id] = aInfo; | ||||||||||||
1486 | } | ||||||||||||
1487 | |||||||||||||
1488 | void VclBuilder::extractButtonImage(const OString &id, stringmap &rMap, bool bRadio) | ||||||||||||
1489 | { | ||||||||||||
1490 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("image")); | ||||||||||||
1491 | if (aFind != rMap.end()) | ||||||||||||
1492 | { | ||||||||||||
1493 | m_pParserState->m_aButtonImageWidgetMaps.emplace_back(id, aFind->second, bRadio); | ||||||||||||
1494 | rMap.erase(aFind); | ||||||||||||
1495 | } | ||||||||||||
1496 | } | ||||||||||||
1497 | |||||||||||||
1498 | void VclBuilder::extractMnemonicWidget(const OString &rLabelID, stringmap &rMap) | ||||||||||||
1499 | { | ||||||||||||
1500 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("mnemonic-widget")); | ||||||||||||
1501 | if (aFind != rMap.end()) | ||||||||||||
1502 | { | ||||||||||||
1503 | OUString sID = aFind->second; | ||||||||||||
1504 | sal_Int32 nDelim = sID.indexOf(':'); | ||||||||||||
1505 | if (nDelim != -1) | ||||||||||||
1506 | sID = sID.copy(0, nDelim); | ||||||||||||
1507 | m_pParserState->m_aMnemonicWidgetMaps.emplace_back(rLabelID, sID); | ||||||||||||
1508 | rMap.erase(aFind); | ||||||||||||
1509 | } | ||||||||||||
1510 | } | ||||||||||||
1511 | |||||||||||||
1512 | vcl::Window* VclBuilder::prepareWidgetOwnScrolling(vcl::Window *pParent, WinBits &rWinStyle) | ||||||||||||
1513 | { | ||||||||||||
1514 | //For Widgets that manage their own scrolling, if one appears as a child of | ||||||||||||
1515 | //a scrolling window shoehorn that scrolling settings to this widget and | ||||||||||||
1516 | //return the real parent to use | ||||||||||||
1517 | if (pParent && pParent->GetType() == WindowType::SCROLLWINDOW) | ||||||||||||
1518 | { | ||||||||||||
1519 | WinBits nScrollBits = pParent->GetStyle(); | ||||||||||||
1520 | nScrollBits &= (WB_AUTOHSCROLL|WB_HSCROLL|WB_AUTOVSCROLL|WB_VSCROLL); | ||||||||||||
1521 | rWinStyle |= nScrollBits; | ||||||||||||
1522 | if (static_cast<VclScrolledWindow*>(pParent)->HasVisibleBorder()) | ||||||||||||
1523 | rWinStyle |= WB_BORDER; | ||||||||||||
1524 | pParent = pParent->GetParent(); | ||||||||||||
1525 | } | ||||||||||||
1526 | |||||||||||||
1527 | return pParent; | ||||||||||||
1528 | } | ||||||||||||
1529 | |||||||||||||
1530 | void VclBuilder::cleanupWidgetOwnScrolling(vcl::Window *pScrollParent, vcl::Window *pWindow, stringmap &rMap) | ||||||||||||
1531 | { | ||||||||||||
1532 | //remove the redundant scrolling parent | ||||||||||||
1533 | sal_Int32 nWidthReq = pScrollParent->get_width_request(); | ||||||||||||
1534 | rMap[OString("width-request")] = OUString::number(nWidthReq); | ||||||||||||
1535 | sal_Int32 nHeightReq = pScrollParent->get_height_request(); | ||||||||||||
1536 | rMap[OString("height-request")] = OUString::number(nHeightReq); | ||||||||||||
1537 | |||||||||||||
1538 | m_pParserState->m_aRedundantParentWidgets[pScrollParent] = pWindow; | ||||||||||||
1539 | } | ||||||||||||
1540 | |||||||||||||
1541 | #ifndef DISABLE_DYNLOADING | ||||||||||||
1542 | |||||||||||||
1543 | extern "C" { static void thisModule() {} } | ||||||||||||
1544 | |||||||||||||
1545 | namespace { | ||||||||||||
1546 | |||||||||||||
1547 | // Don't unload the module on destruction | ||||||||||||
1548 | class NoAutoUnloadModule : public osl::Module | ||||||||||||
1549 | { | ||||||||||||
1550 | public: | ||||||||||||
1551 | ~NoAutoUnloadModule() { release(); } | ||||||||||||
1552 | }; | ||||||||||||
1553 | |||||||||||||
1554 | } | ||||||||||||
1555 | |||||||||||||
1556 | typedef std::map<OUString, std::shared_ptr<NoAutoUnloadModule>> ModuleMap; | ||||||||||||
1557 | static ModuleMap g_aModuleMap; | ||||||||||||
1558 | |||||||||||||
1559 | #if ENABLE_MERGELIBS0 | ||||||||||||
1560 | static std::shared_ptr<NoAutoUnloadModule> g_pMergedLib = std::make_shared<NoAutoUnloadModule>(); | ||||||||||||
1561 | #endif | ||||||||||||
1562 | |||||||||||||
1563 | #ifndef SAL_DLLPREFIX"lib" | ||||||||||||
1564 | # define SAL_DLLPREFIX"lib" "" | ||||||||||||
1565 | #endif | ||||||||||||
1566 | |||||||||||||
1567 | #endif | ||||||||||||
1568 | |||||||||||||
1569 | void VclBuilder::preload() | ||||||||||||
1570 | { | ||||||||||||
1571 | #ifndef DISABLE_DYNLOADING | ||||||||||||
1572 | |||||||||||||
1573 | #if ENABLE_MERGELIBS0 | ||||||||||||
1574 | g_pMergedLib->loadRelative(&thisModule, SVLIBRARY("merged")"lib" "merged" "lo" ".so"); | ||||||||||||
1575 | #else | ||||||||||||
1576 | // find -name '*ui*' | xargs grep 'class=".*lo-' | | ||||||||||||
1577 | // sed 's/.*class="//' | sed 's/-.*$//' | sort | uniq | ||||||||||||
1578 | static const char *aWidgetLibs[] = { | ||||||||||||
1579 | "sfxlo", "svtlo", "svxcorelo", "foruilo", | ||||||||||||
1580 | "vcllo", "svxlo", "cuilo", "swlo", | ||||||||||||
1581 | "swuilo", "sclo", "sdlo", "chartcontrollerlo", | ||||||||||||
1582 | "smlo", "scuilo", "basctllo", "sduilo", | ||||||||||||
1583 | "scnlo", "xsltdlglo", "pcrlo" // "dbulo" | ||||||||||||
1584 | }; | ||||||||||||
1585 | for (const auto & lib : aWidgetLibs) | ||||||||||||
1586 | { | ||||||||||||
1587 | std::unique_ptr<NoAutoUnloadModule> pModule(new NoAutoUnloadModule); | ||||||||||||
1588 | OUString sModule = SAL_DLLPREFIX"lib" + OUString::createFromAscii(lib) + SAL_DLLEXTENSION".so"; | ||||||||||||
1589 | if (pModule->loadRelative(&thisModule, sModule)) | ||||||||||||
1590 | g_aModuleMap.insert(std::make_pair(sModule, std::move(pModule))); | ||||||||||||
1591 | } | ||||||||||||
1592 | #endif // ENABLE_MERGELIBS | ||||||||||||
1593 | #endif // DISABLE_DYNLOADING | ||||||||||||
1594 | } | ||||||||||||
1595 | |||||||||||||
1596 | #if defined DISABLE_DYNLOADING && !HAVE_FEATURE_DESKTOP1 | ||||||||||||
1597 | extern "C" VclBuilder::customMakeWidget lo_get_custom_widget_func(const char* name); | ||||||||||||
1598 | #endif | ||||||||||||
1599 | |||||||||||||
1600 | namespace | ||||||||||||
1601 | { | ||||||||||||
1602 | // Takes a string like "sfxlo-SidebarToolBox" | ||||||||||||
1603 | VclBuilder::customMakeWidget GetCustomMakeWidget(const OString& name) | ||||||||||||
1604 | { | ||||||||||||
1605 | VclBuilder::customMakeWidget pFunction = nullptr; | ||||||||||||
1606 | if (sal_Int32 nDelim = name.indexOf('-'); nDelim != -1) | ||||||||||||
1607 | { | ||||||||||||
1608 | const OString aFunction("make" + name.copy(nDelim + 1)); | ||||||||||||
1609 | const OUString sFunction(OStringToOUString(aFunction, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))); | ||||||||||||
1610 | |||||||||||||
1611 | #ifndef DISABLE_DYNLOADING | ||||||||||||
1612 | const OUString sModule = SAL_DLLPREFIX"lib" | ||||||||||||
1613 | + OStringToOUString(name.copy(0, nDelim), RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))) | ||||||||||||
1614 | + SAL_DLLEXTENSION".so"; | ||||||||||||
1615 | ModuleMap::iterator aI = g_aModuleMap.find(sModule); | ||||||||||||
1616 | if (aI == g_aModuleMap.end()) | ||||||||||||
1617 | { | ||||||||||||
1618 | std::shared_ptr<NoAutoUnloadModule> pModule; | ||||||||||||
1619 | #if ENABLE_MERGELIBS0 | ||||||||||||
1620 | if (!g_pMergedLib->is()) | ||||||||||||
1621 | g_pMergedLib->loadRelative(&thisModule, SVLIBRARY("merged")"lib" "merged" "lo" ".so"); | ||||||||||||
1622 | if ((pFunction = reinterpret_cast<VclBuilder::customMakeWidget>( | ||||||||||||
1623 | g_pMergedLib->getFunctionSymbol(sFunction)))) | ||||||||||||
1624 | pModule = g_pMergedLib; | ||||||||||||
1625 | #endif | ||||||||||||
1626 | if (!pFunction) | ||||||||||||
1627 | { | ||||||||||||
1628 | pModule = std::make_shared<NoAutoUnloadModule>(); | ||||||||||||
1629 | bool ok = pModule->loadRelative(&thisModule, sModule); | ||||||||||||
1630 | if (!ok) | ||||||||||||
1631 | { | ||||||||||||
1632 | #ifdef LINUX1 | ||||||||||||
1633 | // in the case of preloading, we don't have eg. the | ||||||||||||
1634 | // libcuilo.so, but still need to dlsym the symbols - | ||||||||||||
1635 | // which are already in-process | ||||||||||||
1636 | if (comphelper::LibreOfficeKit::isActive()) | ||||||||||||
1637 | { | ||||||||||||
1638 | pFunction = reinterpret_cast<VclBuilder::customMakeWidget>(dlsym(RTLD_DEFAULT((void *) 0), aFunction.getStr())); | ||||||||||||
1639 | ok = !!pFunction; | ||||||||||||
1640 | assert(ok && "couldn't even directly dlsym the sFunction (available via preload)")(static_cast <bool> (ok && "couldn't even directly dlsym the sFunction (available via preload)" ) ? void (0) : __assert_fail ("ok && \"couldn't even directly dlsym the sFunction (available via preload)\"" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 1640, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
1641 | } | ||||||||||||
1642 | #endif | ||||||||||||
1643 | assert(ok && "bad module name in .ui")(static_cast <bool> (ok && "bad module name in .ui" ) ? void (0) : __assert_fail ("ok && \"bad module name in .ui\"" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 1643, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
1644 | } | ||||||||||||
1645 | else | ||||||||||||
1646 | { | ||||||||||||
1647 | pFunction = reinterpret_cast<VclBuilder::customMakeWidget>( | ||||||||||||
1648 | pModule->getFunctionSymbol(sFunction)); | ||||||||||||
1649 | } | ||||||||||||
1650 | } | ||||||||||||
1651 | g_aModuleMap.insert(std::make_pair(sModule, pModule)); | ||||||||||||
1652 | } | ||||||||||||
1653 | else | ||||||||||||
1654 | pFunction = reinterpret_cast<VclBuilder::customMakeWidget>( | ||||||||||||
1655 | aI->second->getFunctionSymbol(sFunction)); | ||||||||||||
1656 | #elif !HAVE_FEATURE_DESKTOP1 | ||||||||||||
1657 | pFunction = lo_get_custom_widget_func(sFunction.toUtf8().getStr()); | ||||||||||||
1658 | SAL_WARN_IF(!pFunction, "vcl.builder", "Could not find " << sFunction)do { if (true && (!pFunction)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "Could not find " << sFunction) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1658" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Could not find " << sFunction ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Could not find " << sFunction; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1658" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "Could not find " << sFunction) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1658" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Could not find " << sFunction ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Could not find " << sFunction; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1658" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
1659 | assert(pFunction)(static_cast <bool> (pFunction) ? void (0) : __assert_fail ("pFunction", "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 1659, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
1660 | #else | ||||||||||||
1661 | pFunction = reinterpret_cast<VclBuilder::customMakeWidget>( | ||||||||||||
1662 | osl_getFunctionSymbol((oslModule)RTLD_DEFAULT((void *) 0), sFunction.pData)); | ||||||||||||
1663 | #endif | ||||||||||||
1664 | } | ||||||||||||
1665 | return pFunction; | ||||||||||||
1666 | } | ||||||||||||
1667 | } | ||||||||||||
1668 | |||||||||||||
1669 | VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &name, const OString &id, | ||||||||||||
1670 | stringmap &rMap) | ||||||||||||
1671 | { | ||||||||||||
1672 | bool bIsPlaceHolder = name.isEmpty(); | ||||||||||||
1673 | bool bVertical = false; | ||||||||||||
1674 | |||||||||||||
1675 | if (pParent && (pParent->GetType() == WindowType::TABCONTROL || | ||||||||||||
1676 | pParent->GetType() == WindowType::VERTICALTABCONTROL)) | ||||||||||||
1677 | { | ||||||||||||
1678 | bool bTopLevel(name == "GtkDialog" || name == "GtkMessageDialog" || | ||||||||||||
1679 | name == "GtkWindow" || name == "GtkPopover" || name == "GtkAssistant"); | ||||||||||||
1680 | if (!bTopLevel) | ||||||||||||
1681 | { | ||||||||||||
1682 | if (pParent->GetType() == WindowType::TABCONTROL) | ||||||||||||
1683 | { | ||||||||||||
1684 | //We have to add a page | ||||||||||||
1685 | //make default pageid == position | ||||||||||||
1686 | TabControl *pTabControl = static_cast<TabControl*>(pParent); | ||||||||||||
1687 | sal_uInt16 nNewPageCount = pTabControl->GetPageCount()+1; | ||||||||||||
1688 | sal_uInt16 nNewPageId = nNewPageCount; | ||||||||||||
1689 | pTabControl->InsertPage(nNewPageId, OUString()); | ||||||||||||
1690 | pTabControl->SetCurPageId(nNewPageId); | ||||||||||||
1691 | SAL_WARN_IF(bIsPlaceHolder, "vcl.builder", "we should have no placeholders for tabpages")do { if (true && (bIsPlaceHolder)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "we should have no placeholders for tabpages" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1691" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "we should have no placeholders for tabpages" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "we should have no placeholders for tabpages"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder") , ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1691" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "we should have no placeholders for tabpages") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1691" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "we should have no placeholders for tabpages" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "we should have no placeholders for tabpages"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder") , ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1691" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
1692 | if (!bIsPlaceHolder) | ||||||||||||
1693 | { | ||||||||||||
1694 | VclPtrInstance<TabPage> pPage(pTabControl); | ||||||||||||
1695 | pPage->Show(); | ||||||||||||
1696 | |||||||||||||
1697 | //Make up a name for it | ||||||||||||
1698 | OString sTabPageId = get_by_window(pParent) + | ||||||||||||
1699 | "-page" + | ||||||||||||
1700 | OString::number(nNewPageCount); | ||||||||||||
1701 | m_aChildren.emplace_back(sTabPageId, pPage, false); | ||||||||||||
1702 | pPage->SetHelpId(m_sHelpRoot + sTabPageId); | ||||||||||||
1703 | |||||||||||||
1704 | pParent = pPage; | ||||||||||||
1705 | |||||||||||||
1706 | pTabControl->SetTabPage(nNewPageId, pPage); | ||||||||||||
1707 | } | ||||||||||||
1708 | } | ||||||||||||
1709 | else | ||||||||||||
1710 | { | ||||||||||||
1711 | VerticalTabControl *pTabControl = static_cast<VerticalTabControl*>(pParent); | ||||||||||||
1712 | SAL_WARN_IF(bIsPlaceHolder, "vcl.builder", "we should have no placeholders for tabpages")do { if (true && (bIsPlaceHolder)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "we should have no placeholders for tabpages" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1712" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "we should have no placeholders for tabpages" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "we should have no placeholders for tabpages"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder") , ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1712" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "we should have no placeholders for tabpages") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1712" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "we should have no placeholders for tabpages" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "we should have no placeholders for tabpages"; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder") , ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "1712" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
1713 | if (!bIsPlaceHolder) | ||||||||||||
1714 | pParent = pTabControl->GetPageParent(); | ||||||||||||
1715 | } | ||||||||||||
1716 | } | ||||||||||||
1717 | } | ||||||||||||
1718 | |||||||||||||
1719 | if (bIsPlaceHolder || name == "GtkTreeSelection") | ||||||||||||
1720 | return nullptr; | ||||||||||||
1721 | |||||||||||||
1722 | ToolBox *pToolBox = (pParent && pParent->GetType() == WindowType::TOOLBOX) ? static_cast<ToolBox*>(pParent) : nullptr; | ||||||||||||
1723 | |||||||||||||
1724 | extractButtonImage(id, rMap, name == "GtkRadioButton"); | ||||||||||||
1725 | |||||||||||||
1726 | VclPtr<vcl::Window> xWindow; | ||||||||||||
1727 | if (name == "GtkDialog" || name == "GtkAssistant") | ||||||||||||
1728 | { | ||||||||||||
1729 | // WB_ALLOWMENUBAR because we don't know in advance if we will encounter | ||||||||||||
1730 | // a menubar, and menubars need a BorderWindow in the toplevel, and | ||||||||||||
1731 | // such border windows need to be in created during the dialog ctor | ||||||||||||
1732 | WinBits nBits = WB_MOVEABLE|WB_3DLOOK|WB_ALLOWMENUBAR; | ||||||||||||
1733 | if (extractResizable(rMap)) | ||||||||||||
1734 | nBits |= WB_SIZEABLE; | ||||||||||||
1735 | if (extractCloseable(rMap)) | ||||||||||||
1736 | nBits |= WB_CLOSEABLE; | ||||||||||||
1737 | Dialog::InitFlag eInit = !pParent ? Dialog::InitFlag::NoParent : Dialog::InitFlag::Default; | ||||||||||||
1738 | if (name == "GtkAssistant") | ||||||||||||
1739 | xWindow = VclPtr<vcl::RoadmapWizard>::Create(pParent, nBits, eInit); | ||||||||||||
1740 | else | ||||||||||||
1741 | xWindow = VclPtr<Dialog>::Create(pParent, nBits, eInit); | ||||||||||||
1742 | #if HAVE_FEATURE_DESKTOP1 | ||||||||||||
1743 | if (!extractModal(rMap)) | ||||||||||||
1744 | xWindow->SetType(WindowType::MODELESSDIALOG); | ||||||||||||
1745 | #endif | ||||||||||||
1746 | } | ||||||||||||
1747 | else if (name == "GtkMessageDialog") | ||||||||||||
1748 | { | ||||||||||||
1749 | WinBits nBits = WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE; | ||||||||||||
1750 | if (extractResizable(rMap)) | ||||||||||||
1751 | nBits |= WB_SIZEABLE; | ||||||||||||
1752 | VclPtr<MessageDialog> xDialog(VclPtr<MessageDialog>::Create(pParent, nBits)); | ||||||||||||
1753 | m_pParserState->m_aMessageDialogs.push_back(xDialog); | ||||||||||||
1754 | xWindow = xDialog; | ||||||||||||
1755 | #if defined _WIN32 | ||||||||||||
1756 | xWindow->set_border_width(3); | ||||||||||||
1757 | #else | ||||||||||||
1758 | xWindow->set_border_width(12); | ||||||||||||
1759 | #endif | ||||||||||||
1760 | } | ||||||||||||
1761 | else if (name == "GtkBox" || name == "GtkStatusbar") | ||||||||||||
1762 | { | ||||||||||||
1763 | bVertical = extractOrientation(rMap); | ||||||||||||
1764 | if (bVertical) | ||||||||||||
1765 | xWindow = VclPtr<VclVBox>::Create(pParent); | ||||||||||||
1766 | else | ||||||||||||
1767 | xWindow = VclPtr<VclHBox>::Create(pParent); | ||||||||||||
1768 | } | ||||||||||||
1769 | else if (name == "GtkPaned") | ||||||||||||
1770 | { | ||||||||||||
1771 | bVertical = extractOrientation(rMap); | ||||||||||||
1772 | if (bVertical) | ||||||||||||
1773 | xWindow = VclPtr<VclVPaned>::Create(pParent); | ||||||||||||
1774 | else | ||||||||||||
1775 | xWindow = VclPtr<VclHPaned>::Create(pParent); | ||||||||||||
1776 | } | ||||||||||||
1777 | else if (name == "GtkHBox") | ||||||||||||
1778 | xWindow = VclPtr<VclHBox>::Create(pParent); | ||||||||||||
1779 | else if (name == "GtkVBox") | ||||||||||||
1780 | xWindow = VclPtr<VclVBox>::Create(pParent); | ||||||||||||
1781 | else if (name == "GtkButtonBox") | ||||||||||||
1782 | { | ||||||||||||
1783 | bVertical = extractOrientation(rMap); | ||||||||||||
1784 | if (bVertical) | ||||||||||||
1785 | xWindow = VclPtr<VclVButtonBox>::Create(pParent); | ||||||||||||
1786 | else | ||||||||||||
1787 | xWindow = VclPtr<VclHButtonBox>::Create(pParent); | ||||||||||||
1788 | } | ||||||||||||
1789 | else if (name == "GtkHButtonBox") | ||||||||||||
1790 | xWindow = VclPtr<VclHButtonBox>::Create(pParent); | ||||||||||||
1791 | else if (name == "GtkVButtonBox") | ||||||||||||
1792 | xWindow = VclPtr<VclVButtonBox>::Create(pParent); | ||||||||||||
1793 | else if (name == "GtkGrid") | ||||||||||||
1794 | xWindow = VclPtr<VclGrid>::Create(pParent); | ||||||||||||
1795 | else if (name == "GtkFrame") | ||||||||||||
1796 | xWindow = VclPtr<VclFrame>::Create(pParent); | ||||||||||||
1797 | else if (name == "GtkExpander") | ||||||||||||
1798 | { | ||||||||||||
1799 | VclPtrInstance<VclExpander> pExpander(pParent); | ||||||||||||
1800 | m_pParserState->m_aExpanderWidgets.push_back(pExpander); | ||||||||||||
1801 | xWindow = pExpander; | ||||||||||||
1802 | } | ||||||||||||
1803 | else if (name == "GtkAlignment") | ||||||||||||
1804 | xWindow = VclPtr<VclAlignment>::Create(pParent); | ||||||||||||
1805 | else if (name == "GtkButton" || (!m_bLegacy && name == "GtkToggleButton")) | ||||||||||||
1806 | { | ||||||||||||
1807 | VclPtr<Button> xButton; | ||||||||||||
1808 | OUString sMenu = BuilderUtils::extractCustomProperty(rMap); | ||||||||||||
1809 | if (sMenu.isEmpty()) | ||||||||||||
1810 | xButton = extractStockAndBuildPushButton(pParent, rMap, name == "GtkToggleButton", m_bLegacy); | ||||||||||||
1811 | else | ||||||||||||
1812 | { | ||||||||||||
1813 | assert(m_bLegacy && "use GtkMenuButton")(static_cast <bool> (m_bLegacy && "use GtkMenuButton" ) ? void (0) : __assert_fail ("m_bLegacy && \"use GtkMenuButton\"" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 1813, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
1814 | xButton = extractStockAndBuildMenuButton(pParent, rMap); | ||||||||||||
1815 | m_pParserState->m_aButtonMenuMaps.emplace_back(id, sMenu); | ||||||||||||
1816 | } | ||||||||||||
1817 | xButton->SetImageAlign(ImageAlign::Left); //default to left | ||||||||||||
1818 | setupFromActionName(xButton, rMap, m_xFrame); | ||||||||||||
1819 | xWindow = xButton; | ||||||||||||
1820 | } | ||||||||||||
1821 | else if (name == "GtkMenuButton") | ||||||||||||
1822 | { | ||||||||||||
1823 | VclPtr<MenuButton> xButton = extractStockAndBuildMenuButton(pParent, rMap); | ||||||||||||
1824 | OUString sMenu = extractPopupMenu(rMap); | ||||||||||||
1825 | if (!sMenu.isEmpty()) | ||||||||||||
1826 | m_pParserState->m_aButtonMenuMaps.emplace_back(id, sMenu); | ||||||||||||
1827 | xButton->SetImageAlign(ImageAlign::Left); //default to left | ||||||||||||
1828 | xButton->SetAccessibleRole(css::accessibility::AccessibleRole::BUTTON_MENU); | ||||||||||||
1829 | |||||||||||||
1830 | if (!extractDrawIndicator(rMap)) | ||||||||||||
1831 | xButton->SetDropDown(PushButtonDropdownStyle::NONE); | ||||||||||||
1832 | |||||||||||||
1833 | setupFromActionName(xButton, rMap, m_xFrame); | ||||||||||||
1834 | xWindow = xButton; | ||||||||||||
1835 | } | ||||||||||||
1836 | else if (name == "GtkToggleButton" && m_bLegacy) | ||||||||||||
1837 | { | ||||||||||||
1838 | VclPtr<Button> xButton; | ||||||||||||
1839 | OUString sMenu = BuilderUtils::extractCustomProperty(rMap); | ||||||||||||
1840 | assert(sMenu.getLength() && "not implemented yet")(static_cast <bool> (sMenu.getLength() && "not implemented yet" ) ? void (0) : __assert_fail ("sMenu.getLength() && \"not implemented yet\"" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 1840, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
1841 | xButton = extractStockAndBuildMenuToggleButton(pParent, rMap); | ||||||||||||
1842 | m_pParserState->m_aButtonMenuMaps.emplace_back(id, sMenu); | ||||||||||||
1843 | xButton->SetImageAlign(ImageAlign::Left); //default to left | ||||||||||||
1844 | setupFromActionName(xButton, rMap, m_xFrame); | ||||||||||||
1845 | xWindow = xButton; | ||||||||||||
1846 | } | ||||||||||||
1847 | else if (name == "GtkRadioButton") | ||||||||||||
1848 | { | ||||||||||||
1849 | extractGroup(id, rMap); | ||||||||||||
1850 | WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK; | ||||||||||||
1851 | VclPtr<RadioButton> xButton = VclPtr<RadioButton>::Create(pParent, nBits); | ||||||||||||
1852 | xButton->SetImageAlign(ImageAlign::Left); //default to left | ||||||||||||
1853 | xWindow = xButton; | ||||||||||||
1854 | |||||||||||||
1855 | if (::extractStock(rMap)) | ||||||||||||
1856 | { | ||||||||||||
1857 | xWindow->SetText(getStockText(extractLabel(rMap))); | ||||||||||||
1858 | } | ||||||||||||
1859 | } | ||||||||||||
1860 | else if (name == "GtkCheckButton") | ||||||||||||
1861 | { | ||||||||||||
1862 | WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK; | ||||||||||||
1863 | bool bIsTriState = extractInconsistent(rMap); | ||||||||||||
1864 | VclPtr<CheckBox> xCheckBox = VclPtr<CheckBox>::Create(pParent, nBits); | ||||||||||||
1865 | if (bIsTriState) | ||||||||||||
1866 | { | ||||||||||||
1867 | xCheckBox->EnableTriState(true); | ||||||||||||
1868 | xCheckBox->SetState(TRISTATE_INDET); | ||||||||||||
1869 | } | ||||||||||||
1870 | xCheckBox->SetImageAlign(ImageAlign::Left); //default to left | ||||||||||||
1871 | |||||||||||||
1872 | xWindow = xCheckBox; | ||||||||||||
1873 | |||||||||||||
1874 | if (::extractStock(rMap)) | ||||||||||||
1875 | { | ||||||||||||
1876 | xWindow->SetText(getStockText(extractLabel(rMap))); | ||||||||||||
1877 | } | ||||||||||||
1878 | } | ||||||||||||
1879 | else if (name == "GtkSpinButton") | ||||||||||||
1880 | { | ||||||||||||
1881 | OUString sAdjustment = extractAdjustment(rMap); | ||||||||||||
1882 | |||||||||||||
1883 | WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_3DLOOK|WB_SPIN|WB_REPEAT; | ||||||||||||
1884 | if (extractHasFrame(rMap)) | ||||||||||||
1885 | nBits |= WB_BORDER; | ||||||||||||
1886 | |||||||||||||
1887 | connectFormattedFormatterAdjustment(id, sAdjustment); | ||||||||||||
1888 | VclPtrInstance<FormattedField> xField(pParent, nBits); | ||||||||||||
1889 | xField->GetFormatter().SetMinValue(0); | ||||||||||||
1890 | xWindow = xField; | ||||||||||||
1891 | } | ||||||||||||
1892 | else if (name == "GtkLinkButton") | ||||||||||||
1893 | xWindow = VclPtr<FixedHyperlink>::Create(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK|WB_NOLABEL); | ||||||||||||
1894 | else if (name == "GtkComboBox" || name == "GtkComboBoxText") | ||||||||||||
1895 | { | ||||||||||||
1896 | extractModel(id, rMap); | ||||||||||||
1897 | |||||||||||||
1898 | WinBits nBits = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK; | ||||||||||||
1899 | |||||||||||||
1900 | bool bDropdown = BuilderUtils::extractDropdown(rMap); | ||||||||||||
1901 | |||||||||||||
1902 | if (bDropdown) | ||||||||||||
1903 | nBits |= WB_DROPDOWN; | ||||||||||||
1904 | |||||||||||||
1905 | if (extractEntry(rMap)) | ||||||||||||
1906 | { | ||||||||||||
1907 | VclPtrInstance<ComboBox> xComboBox(pParent, nBits); | ||||||||||||
1908 | xComboBox->EnableAutoSize(true); | ||||||||||||
1909 | xWindow = xComboBox; | ||||||||||||
1910 | } | ||||||||||||
1911 | else | ||||||||||||
1912 | { | ||||||||||||
1913 | VclPtrInstance<ListBox> xListBox(pParent, nBits|WB_SIMPLEMODE); | ||||||||||||
1914 | xListBox->EnableAutoSize(true); | ||||||||||||
1915 | xWindow = xListBox; | ||||||||||||
1916 | } | ||||||||||||
1917 | } | ||||||||||||
1918 | else if (name == "VclOptionalBox" || name == "sfxlo-OptionalBox") | ||||||||||||
1919 | { | ||||||||||||
1920 | // tdf#135495 fallback sfxlo-OptionalBox to VclOptionalBox as a stopgap | ||||||||||||
1921 | xWindow = VclPtr<OptionalBox>::Create(pParent); | ||||||||||||
1922 | } | ||||||||||||
1923 | else if (name == "GtkIconView") | ||||||||||||
1924 | { | ||||||||||||
1925 | assert(rMap.find(OString("model")) != rMap.end() && "GtkIconView must have a model")(static_cast <bool> (rMap.find(OString("model")) != rMap .end() && "GtkIconView must have a model") ? void (0) : __assert_fail ("rMap.find(OString(\"model\")) != rMap.end() && \"GtkIconView must have a model\"" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 1925, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
1926 | |||||||||||||
1927 | //window we want to apply the packing props for this GtkIconView to | ||||||||||||
1928 | VclPtr<vcl::Window> xWindowForPackingProps; | ||||||||||||
1929 | extractModel(id, rMap); | ||||||||||||
1930 | WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK; | ||||||||||||
1931 | //IconView manages its own scrolling, | ||||||||||||
1932 | vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle); | ||||||||||||
1933 | |||||||||||||
1934 | VclPtr<IconView> xBox = VclPtr<IconView>::Create(pRealParent, nWinStyle); | ||||||||||||
1935 | xWindowForPackingProps = xBox; | ||||||||||||
1936 | |||||||||||||
1937 | xWindow = xBox; | ||||||||||||
1938 | xBox->SetNoAutoCurEntry(true); | ||||||||||||
1939 | xBox->SetQuickSearch(true); | ||||||||||||
1940 | |||||||||||||
1941 | if (pRealParent != pParent) | ||||||||||||
1942 | cleanupWidgetOwnScrolling(pParent, xWindowForPackingProps, rMap); | ||||||||||||
1943 | } | ||||||||||||
1944 | else if (name == "GtkTreeView") | ||||||||||||
1945 | { | ||||||||||||
1946 | if (!m_bLegacy) | ||||||||||||
1947 | { | ||||||||||||
1948 | assert(rMap.find(OString("model")) != rMap.end() && "GtkTreeView must have a model")(static_cast <bool> (rMap.find(OString("model")) != rMap .end() && "GtkTreeView must have a model") ? void (0) : __assert_fail ("rMap.find(OString(\"model\")) != rMap.end() && \"GtkTreeView must have a model\"" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 1948, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
1949 | } | ||||||||||||
1950 | |||||||||||||
1951 | //window we want to apply the packing props for this GtkTreeView to | ||||||||||||
1952 | VclPtr<vcl::Window> xWindowForPackingProps; | ||||||||||||
1953 | //To-Do | ||||||||||||
1954 | //a) make SvHeaderTabListBox/SvTabListBox the default target for GtkTreeView | ||||||||||||
1955 | //b) remove the non-drop down mode of ListBox and convert | ||||||||||||
1956 | // everything over to SvHeaderTabListBox/SvTabListBox | ||||||||||||
1957 | //c) remove the users of makeSvTabListBox and makeSvTreeListBox | ||||||||||||
1958 | extractModel(id, rMap); | ||||||||||||
1959 | WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK; | ||||||||||||
1960 | if (m_bLegacy) | ||||||||||||
1961 | { | ||||||||||||
1962 | OUString sBorder = BuilderUtils::extractCustomProperty(rMap); | ||||||||||||
1963 | if (!sBorder.isEmpty()) | ||||||||||||
1964 | nWinStyle |= WB_BORDER; | ||||||||||||
1965 | } | ||||||||||||
1966 | else | ||||||||||||
1967 | { | ||||||||||||
1968 | nWinStyle |= WB_HASBUTTONS | WB_HASBUTTONSATROOT; | ||||||||||||
1969 | } | ||||||||||||
1970 | //ListBox/SvHeaderTabListBox manages its own scrolling, | ||||||||||||
1971 | vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle); | ||||||||||||
1972 | if (m_bLegacy) | ||||||||||||
1973 | { | ||||||||||||
1974 | xWindow = VclPtr<ListBox>::Create(pRealParent, nWinStyle | WB_SIMPLEMODE); | ||||||||||||
1975 | xWindowForPackingProps = xWindow; | ||||||||||||
1976 | } | ||||||||||||
1977 | else | ||||||||||||
1978 | { | ||||||||||||
1979 | VclPtr<SvTabListBox> xBox; | ||||||||||||
1980 | bool bHeadersVisible = extractHeadersVisible(rMap); | ||||||||||||
1981 | if (bHeadersVisible) | ||||||||||||
1982 | { | ||||||||||||
1983 | VclPtr<VclVBox> xContainer = VclPtr<VclVBox>::Create(pRealParent); | ||||||||||||
1984 | OString containerid(id + "-container"); | ||||||||||||
1985 | xContainer->SetHelpId(m_sHelpRoot + containerid); | ||||||||||||
1986 | m_aChildren.emplace_back(containerid, xContainer, true); | ||||||||||||
1987 | |||||||||||||
1988 | VclPtrInstance<HeaderBar> xHeader(xContainer, WB_BUTTONSTYLE(WinBits(0x0800)) | WB_BORDER | WB_TABSTOP | WB_3DLOOK); | ||||||||||||
1989 | xHeader->set_width_request(0); // let the headerbar width not affect the size request | ||||||||||||
1990 | OString headerid(id + "-header"); | ||||||||||||
1991 | xHeader->SetHelpId(m_sHelpRoot + headerid); | ||||||||||||
1992 | m_aChildren.emplace_back(headerid, xHeader, true); | ||||||||||||
1993 | |||||||||||||
1994 | VclPtr<LclHeaderTabListBox> xHeaderBox = VclPtr<LclHeaderTabListBox>::Create(xContainer, nWinStyle); | ||||||||||||
1995 | xHeaderBox->InitHeaderBar(xHeader); | ||||||||||||
1996 | xContainer->set_expand(true); | ||||||||||||
1997 | xHeader->Show(); | ||||||||||||
1998 | xContainer->Show(); | ||||||||||||
1999 | xBox = xHeaderBox; | ||||||||||||
2000 | xWindowForPackingProps = xContainer; | ||||||||||||
2001 | } | ||||||||||||
2002 | else | ||||||||||||
2003 | { | ||||||||||||
2004 | xBox = VclPtr<LclTabListBox>::Create(pRealParent, nWinStyle); | ||||||||||||
2005 | xWindowForPackingProps = xBox; | ||||||||||||
2006 | } | ||||||||||||
2007 | xWindow = xBox; | ||||||||||||
2008 | xBox->SetNoAutoCurEntry(true); | ||||||||||||
2009 | xBox->SetQuickSearch(true); | ||||||||||||
2010 | xBox->SetSpaceBetweenEntries(3); | ||||||||||||
2011 | xBox->SetEntryHeight(16); | ||||||||||||
2012 | xBox->SetHighlightRange(); // select over the whole width | ||||||||||||
2013 | } | ||||||||||||
2014 | if (pRealParent != pParent) | ||||||||||||
2015 | cleanupWidgetOwnScrolling(pParent, xWindowForPackingProps, rMap); | ||||||||||||
2016 | } | ||||||||||||
2017 | else if (name == "GtkTreeViewColumn") | ||||||||||||
2018 | { | ||||||||||||
2019 | if (!m_bLegacy) | ||||||||||||
2020 | { | ||||||||||||
2021 | SvHeaderTabListBox* pTreeView = dynamic_cast<SvHeaderTabListBox*>(pParent); | ||||||||||||
2022 | if (HeaderBar* pHeaderBar = pTreeView ? pTreeView->GetHeaderBar() : nullptr) | ||||||||||||
2023 | { | ||||||||||||
2024 | HeaderBarItemBits nBits = HeaderBarItemBits::LEFTIMAGE; | ||||||||||||
2025 | if (extractClickable(rMap)) | ||||||||||||
2026 | nBits |= HeaderBarItemBits::CLICKABLE; | ||||||||||||
2027 | if (extractSortIndicator(rMap)) | ||||||||||||
2028 | nBits |= HeaderBarItemBits::DOWNARROW; | ||||||||||||
2029 | float fAlign = extractAlignment(rMap); | ||||||||||||
2030 | if (fAlign == 0.0) | ||||||||||||
2031 | nBits |= HeaderBarItemBits::LEFT; | ||||||||||||
2032 | else if (fAlign == 1.0) | ||||||||||||
2033 | nBits |= HeaderBarItemBits::RIGHT; | ||||||||||||
2034 | else if (fAlign == 0.5) | ||||||||||||
2035 | nBits |= HeaderBarItemBits::CENTER; | ||||||||||||
2036 | auto nItemId = pHeaderBar->GetItemCount() + 1; | ||||||||||||
2037 | OUString sTitle(extractTitle(rMap)); | ||||||||||||
2038 | pHeaderBar->InsertItem(nItemId, sTitle, 100, nBits); | ||||||||||||
2039 | } | ||||||||||||
2040 | } | ||||||||||||
2041 | } | ||||||||||||
2042 | else if (name == "GtkLabel") | ||||||||||||
2043 | { | ||||||||||||
2044 | WinBits nWinStyle = WB_CENTER|WB_VCENTER|WB_3DLOOK; | ||||||||||||
2045 | extractMnemonicWidget(id, rMap); | ||||||||||||
2046 | if (extractSelectable(rMap)) | ||||||||||||
2047 | xWindow = VclPtr<SelectableFixedText>::Create(pParent, nWinStyle); | ||||||||||||
2048 | else | ||||||||||||
2049 | xWindow = VclPtr<FixedText>::Create(pParent, nWinStyle); | ||||||||||||
2050 | } | ||||||||||||
2051 | else if (name == "GtkImage") | ||||||||||||
2052 | { | ||||||||||||
2053 | extractStock(id, rMap); | ||||||||||||
2054 | xWindow = VclPtr<FixedImage>::Create(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK|WB_SCALE); | ||||||||||||
2055 | //such parentless GtkImages are temps used to set icons on buttons | ||||||||||||
2056 | //default them to hidden to stop e.g. insert->index entry flicking temp | ||||||||||||
2057 | //full screen windows | ||||||||||||
2058 | if (!pParent) | ||||||||||||
2059 | { | ||||||||||||
2060 | rMap["visible"] = "false"; | ||||||||||||
2061 | } | ||||||||||||
2062 | } | ||||||||||||
2063 | else if (name == "GtkSeparator") | ||||||||||||
2064 | { | ||||||||||||
2065 | bVertical = extractOrientation(rMap); | ||||||||||||
2066 | xWindow = VclPtr<FixedLine>::Create(pParent, bVertical ? WB_VERT : WB_HORZ); | ||||||||||||
2067 | } | ||||||||||||
2068 | else if (name == "GtkScrollbar") | ||||||||||||
2069 | { | ||||||||||||
2070 | extractAdjustmentToMap(id, rMap, m_pParserState->m_aScrollAdjustmentMaps); | ||||||||||||
2071 | bVertical = extractOrientation(rMap); | ||||||||||||
2072 | xWindow = VclPtr<ScrollBar>::Create(pParent, bVertical ? WB_VERT : WB_HORZ); | ||||||||||||
2073 | } | ||||||||||||
2074 | else if (name == "GtkProgressBar") | ||||||||||||
2075 | { | ||||||||||||
2076 | extractAdjustmentToMap(id, rMap, m_pParserState->m_aScrollAdjustmentMaps); | ||||||||||||
2077 | bVertical = extractOrientation(rMap); | ||||||||||||
2078 | xWindow = VclPtr<ProgressBar>::Create(pParent, bVertical ? WB_VERT : WB_HORZ); | ||||||||||||
2079 | } | ||||||||||||
2080 | else if (name == "GtkScrolledWindow") | ||||||||||||
2081 | { | ||||||||||||
2082 | xWindow = VclPtr<VclScrolledWindow>::Create(pParent); | ||||||||||||
2083 | } | ||||||||||||
2084 | else if (name == "GtkViewport") | ||||||||||||
2085 | { | ||||||||||||
2086 | xWindow = VclPtr<VclViewport>::Create(pParent); | ||||||||||||
2087 | } | ||||||||||||
2088 | else if (name == "GtkEventBox") | ||||||||||||
2089 | { | ||||||||||||
2090 | xWindow = VclPtr<VclEventBox>::Create(pParent); | ||||||||||||
2091 | } | ||||||||||||
2092 | else if (name == "GtkEntry") | ||||||||||||
2093 | { | ||||||||||||
2094 | WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK; | ||||||||||||
2095 | if (extractHasFrame(rMap)) | ||||||||||||
2096 | nWinStyle |= WB_BORDER; | ||||||||||||
2097 | xWindow = VclPtr<Edit>::Create(pParent, nWinStyle); | ||||||||||||
2098 | BuilderUtils::ensureDefaultWidthChars(rMap); | ||||||||||||
2099 | } | ||||||||||||
2100 | else if (name == "GtkNotebook") | ||||||||||||
2101 | { | ||||||||||||
2102 | if (!extractVerticalTabPos(rMap)) | ||||||||||||
2103 | xWindow = VclPtr<TabControl>::Create(pParent, WB_STDTABCONTROL|WB_3DLOOK); | ||||||||||||
2104 | else | ||||||||||||
2105 | xWindow = VclPtr<VerticalTabControl>::Create(pParent); | ||||||||||||
2106 | } | ||||||||||||
2107 | else if (name == "GtkDrawingArea") | ||||||||||||
2108 | { | ||||||||||||
2109 | xWindow = VclPtr<VclDrawingArea>::Create(pParent, WB_TABSTOP); | ||||||||||||
2110 | } | ||||||||||||
2111 | else if (name == "GtkTextView") | ||||||||||||
2112 | { | ||||||||||||
2113 | extractBuffer(id, rMap); | ||||||||||||
2114 | |||||||||||||
2115 | WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT; | ||||||||||||
2116 | //VclMultiLineEdit manages its own scrolling, | ||||||||||||
2117 | vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle); | ||||||||||||
2118 | xWindow = VclPtr<VclMultiLineEdit>::Create(pRealParent, nWinStyle); | ||||||||||||
2119 | if (pRealParent != pParent) | ||||||||||||
2120 | cleanupWidgetOwnScrolling(pParent, xWindow, rMap); | ||||||||||||
2121 | } | ||||||||||||
2122 | else if (name == "GtkSpinner") | ||||||||||||
2123 | { | ||||||||||||
2124 | xWindow = VclPtr<Throbber>::Create(pParent, WB_3DLOOK); | ||||||||||||
2125 | } | ||||||||||||
2126 | else if (name == "GtkScale") | ||||||||||||
2127 | { | ||||||||||||
2128 | extractAdjustmentToMap(id, rMap, m_pParserState->m_aSliderAdjustmentMaps); | ||||||||||||
2129 | bool bDrawValue = extractDrawValue(rMap); | ||||||||||||
2130 | if (bDrawValue) | ||||||||||||
2131 | { | ||||||||||||
2132 | OUString sValuePos = extractValuePos(rMap); | ||||||||||||
2133 | (void)sValuePos; | ||||||||||||
2134 | } | ||||||||||||
2135 | bVertical = extractOrientation(rMap); | ||||||||||||
2136 | |||||||||||||
2137 | WinBits nWinStyle = bVertical ? WB_VERT : WB_HORZ; | ||||||||||||
2138 | |||||||||||||
2139 | xWindow = VclPtr<Slider>::Create(pParent, nWinStyle); | ||||||||||||
2140 | } | ||||||||||||
2141 | else if (name == "GtkToolbar") | ||||||||||||
2142 | { | ||||||||||||
2143 | xWindow = VclPtr<ToolBox>::Create(pParent, WB_3DLOOK | WB_TABSTOP); | ||||||||||||
2144 | } | ||||||||||||
2145 | else if(name == "NotebookBarAddonsToolMergePoint") | ||||||||||||
2146 | { | ||||||||||||
2147 | customMakeWidget pFunction = GetCustomMakeWidget("sfxlo-NotebookbarToolBox"); | ||||||||||||
2148 | if(pFunction != nullptr) | ||||||||||||
2149 | NotebookBarAddonsMerger::MergeNotebookBarAddons(pParent, pFunction, m_xFrame, *m_pNotebookBarAddonsItem, rMap); | ||||||||||||
2150 | return nullptr; | ||||||||||||
2151 | } | ||||||||||||
2152 | else if (name == "GtkToolButton" || name == "GtkMenuToolButton" || | ||||||||||||
2153 | name == "GtkToggleToolButton" || name == "GtkRadioToolButton" || name == "GtkToolItem") | ||||||||||||
2154 | { | ||||||||||||
2155 | if (pToolBox) | ||||||||||||
2156 | { | ||||||||||||
2157 | OUString aCommand(extractActionName(rMap)); | ||||||||||||
2158 | |||||||||||||
2159 | sal_uInt16 nItemId = 0; | ||||||||||||
2160 | ToolBoxItemBits nBits = ToolBoxItemBits::NONE; | ||||||||||||
2161 | if (name == "GtkMenuToolButton") | ||||||||||||
2162 | nBits |= ToolBoxItemBits::DROPDOWN; | ||||||||||||
2163 | else if (name == "GtkToggleToolButton") | ||||||||||||
2164 | nBits |= ToolBoxItemBits::AUTOCHECK | ToolBoxItemBits::CHECKABLE; | ||||||||||||
2165 | else if (name == "GtkRadioToolButton") | ||||||||||||
2166 | nBits |= ToolBoxItemBits::AUTOCHECK | ToolBoxItemBits::RADIOCHECK; | ||||||||||||
2167 | |||||||||||||
2168 | if (!aCommand.isEmpty() && m_xFrame.is()) | ||||||||||||
2169 | { | ||||||||||||
2170 | pToolBox->InsertItem(aCommand, m_xFrame, nBits, extractSizeRequest(rMap)); | ||||||||||||
2171 | nItemId = pToolBox->GetItemId(aCommand); | ||||||||||||
2172 | } | ||||||||||||
2173 | else | ||||||||||||
2174 | { | ||||||||||||
2175 | nItemId = pToolBox->GetItemCount() + 1; | ||||||||||||
2176 | //TODO: ImplToolItems::size_type -> sal_uInt16! | ||||||||||||
2177 | pToolBox->InsertItem(nItemId, extractLabel(rMap), nBits); | ||||||||||||
2178 | if (aCommand.isEmpty() && !m_bLegacy) | ||||||||||||
2179 | aCommand = OUString::fromUtf8(id); | ||||||||||||
2180 | pToolBox->SetItemCommand(nItemId, aCommand); | ||||||||||||
2181 | } | ||||||||||||
2182 | |||||||||||||
2183 | pToolBox->SetHelpId(nItemId, m_sHelpRoot + id); | ||||||||||||
2184 | OUString sTooltip(extractTooltipText(rMap)); | ||||||||||||
2185 | if (!sTooltip.isEmpty()) | ||||||||||||
2186 | pToolBox->SetQuickHelpText(nItemId, sTooltip); | ||||||||||||
2187 | |||||||||||||
2188 | OUString sIconName(extractIconName(rMap)); | ||||||||||||
2189 | if (sIconName.isEmpty()) | ||||||||||||
2190 | sIconName = mapStockToImageResource(extractStockId(rMap)); | ||||||||||||
2191 | if (!sIconName.isEmpty()) | ||||||||||||
2192 | pToolBox->SetItemImage(nItemId, FixedImage::loadThemeImage(sIconName)); | ||||||||||||
2193 | |||||||||||||
2194 | if (!extractVisible(rMap)) | ||||||||||||
2195 | pToolBox->HideItem(nItemId); | ||||||||||||
2196 | |||||||||||||
2197 | m_pParserState->m_nLastToolbarId = nItemId; | ||||||||||||
2198 | |||||||||||||
2199 | return nullptr; // no widget to be created | ||||||||||||
2200 | } | ||||||||||||
2201 | } | ||||||||||||
2202 | else if (name == "GtkSeparatorToolItem") | ||||||||||||
2203 | { | ||||||||||||
2204 | if (pToolBox) | ||||||||||||
2205 | { | ||||||||||||
2206 | pToolBox->InsertSeparator(); | ||||||||||||
2207 | return nullptr; // no widget to be created | ||||||||||||
2208 | } | ||||||||||||
2209 | } | ||||||||||||
2210 | else if (name == "GtkWindow") | ||||||||||||
2211 | { | ||||||||||||
2212 | WinBits nBits = extractDeferredBits(rMap); | ||||||||||||
2213 | if (nBits & WB_DOCKABLE) | ||||||||||||
2214 | xWindow = VclPtr<DockingWindow>::Create(pParent, nBits|WB_MOVEABLE); | ||||||||||||
2215 | else | ||||||||||||
2216 | xWindow = VclPtr<FloatingWindow>::Create(pParent, nBits|WB_MOVEABLE); | ||||||||||||
2217 | } | ||||||||||||
2218 | else if (name == "GtkPopover") | ||||||||||||
2219 | { | ||||||||||||
2220 | WinBits nBits = extractDeferredBits(rMap); | ||||||||||||
2221 | xWindow = VclPtr<DockingWindow>::Create(pParent, nBits|WB_DOCKABLE|WB_MOVEABLE); | ||||||||||||
2222 | } | ||||||||||||
2223 | else if (name == "GtkCalendar") | ||||||||||||
2224 | { | ||||||||||||
2225 | WinBits nBits = extractDeferredBits(rMap); | ||||||||||||
2226 | xWindow = VclPtr<Calendar>::Create(pParent, nBits); | ||||||||||||
2227 | } | ||||||||||||
2228 | else | ||||||||||||
2229 | { | ||||||||||||
2230 | if (customMakeWidget pFunction = GetCustomMakeWidget(name)) | ||||||||||||
2231 | { | ||||||||||||
2232 | pFunction(xWindow, pParent, rMap); | ||||||||||||
2233 | if (xWindow->GetType() == WindowType::PUSHBUTTON) | ||||||||||||
2234 | setupFromActionName(static_cast<Button*>(xWindow.get()), rMap, m_xFrame); | ||||||||||||
2235 | else if (xWindow->GetType() == WindowType::MENUBUTTON) | ||||||||||||
2236 | { | ||||||||||||
2237 | OUString sMenu = BuilderUtils::extractCustomProperty(rMap); | ||||||||||||
2238 | if (!sMenu.isEmpty()) | ||||||||||||
2239 | m_pParserState->m_aButtonMenuMaps.emplace_back(id, sMenu); | ||||||||||||
2240 | setupFromActionName(static_cast<Button*>(xWindow.get()), rMap, m_xFrame); | ||||||||||||
2241 | } | ||||||||||||
2242 | } | ||||||||||||
2243 | } | ||||||||||||
2244 | |||||||||||||
2245 | SAL_INFO_IF(!xWindow, "vcl.builder", "probably need to implement " << name << " or add a make" << name << " function")do { if (true && (!xWindow)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_INFO, "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "probably need to implement " << name << " or add a make" << name << " function") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2245" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "probably need to implement " << name << " or add a make" << name << " function" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "probably need to implement " << name << " or add a make" << name << " function"; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ( "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2245" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "probably need to implement " << name << " or add a make" << name << " function") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2245" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "probably need to implement " << name << " or add a make" << name << " function" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "probably need to implement " << name << " or add a make" << name << " function"; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ( "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2245" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
2246 | if (xWindow) | ||||||||||||
2247 | { | ||||||||||||
2248 | // child windows of disabled windows are made disabled by vcl by default, we don't want that | ||||||||||||
2249 | WindowImpl *pWindowImpl = xWindow->ImplGetWindowImpl(); | ||||||||||||
2250 | pWindowImpl->mbDisabled = false; | ||||||||||||
2251 | |||||||||||||
2252 | xWindow->SetHelpId(m_sHelpRoot + id); | ||||||||||||
2253 | SAL_INFO("vcl.builder", "for name '" << name << "' and id '" << id <<do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl()->mpParent .get() << "/" << xWindow->ImplGetWindowImpl()-> mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | ||||||||||||
2254 | "', created " << xWindow.get() << " child of " <<do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl()->mpParent .get() << "/" << xWindow->ImplGetWindowImpl()-> mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | ||||||||||||
2255 | pParent << "(" << xWindow->ImplGetWindowImpl()->mpParent.get() << "/" <<do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl()->mpParent .get() << "/" << xWindow->ImplGetWindowImpl()-> mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | ||||||||||||
2256 | xWindow->ImplGetWindowImpl()->mpRealParent.get() << "/" <<do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl()->mpParent .get() << "/" << xWindow->ImplGetWindowImpl()-> mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | ||||||||||||
2257 | xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " <<do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl()->mpParent .get() << "/" << xWindow->ImplGetWindowImpl()-> mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | ||||||||||||
2258 | xWindow->GetHelpId())do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl()->mpParent .get() << "/" << xWindow->ImplGetWindowImpl()-> mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow-> ImplGetWindowImpl()->mpParent.get() << "/" << xWindow ->ImplGetWindowImpl()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "for name '" << name << "' and id '" << id << "', created " << xWindow.get() << " child of " << pParent << "(" << xWindow->ImplGetWindowImpl ()->mpParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpRealParent.get() << "/" << xWindow->ImplGetWindowImpl ()->mpBorderWindow.get() << ") with helpid " << xWindow->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2258" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
2259 | m_aChildren.emplace_back(id, xWindow, bVertical); | ||||||||||||
2260 | |||||||||||||
2261 | // if the parent was a toolbox set it as an itemwindow for the latest itemid | ||||||||||||
2262 | if (pToolBox) | ||||||||||||
2263 | { | ||||||||||||
2264 | Size aSize(xWindow->GetSizePixel()); | ||||||||||||
2265 | aSize.setHeight(xWindow->get_preferred_size().Height()); | ||||||||||||
2266 | xWindow->SetSizePixel(aSize); | ||||||||||||
2267 | pToolBox->SetItemWindow(m_pParserState->m_nLastToolbarId, xWindow); | ||||||||||||
2268 | pToolBox->SetItemExpand(m_pParserState->m_nLastToolbarId, true); | ||||||||||||
2269 | } | ||||||||||||
2270 | } | ||||||||||||
2271 | return xWindow; | ||||||||||||
2272 | } | ||||||||||||
2273 | |||||||||||||
2274 | namespace | ||||||||||||
2275 | { | ||||||||||||
2276 | //return true for window types which exist in vcl but are not themselves | ||||||||||||
2277 | //represented in the .ui format, i.e. only their children exist. | ||||||||||||
2278 | bool isConsideredGtkPseudo(vcl::Window const *pWindow) | ||||||||||||
2279 | { | ||||||||||||
2280 | return pWindow->GetType() == WindowType::TABPAGE; | ||||||||||||
2281 | } | ||||||||||||
2282 | } | ||||||||||||
2283 | |||||||||||||
2284 | //Any properties from .ui load we couldn't set because of potential virtual methods | ||||||||||||
2285 | //during ctor are applied here | ||||||||||||
2286 | void VclBuilder::setDeferredProperties() | ||||||||||||
2287 | { | ||||||||||||
2288 | if (!m_bToplevelHasDeferredProperties) | ||||||||||||
2289 | return; | ||||||||||||
2290 | stringmap aDeferredProperties; | ||||||||||||
2291 | aDeferredProperties.swap(m_aDeferredProperties); | ||||||||||||
2292 | m_bToplevelHasDeferredProperties = false; | ||||||||||||
2293 | BuilderUtils::set_properties(m_pParent, aDeferredProperties); | ||||||||||||
2294 | } | ||||||||||||
2295 | |||||||||||||
2296 | namespace BuilderUtils | ||||||||||||
2297 | { | ||||||||||||
2298 | void set_properties(vcl::Window *pWindow, const VclBuilder::stringmap &rProps) | ||||||||||||
2299 | { | ||||||||||||
2300 | for (auto const& prop : rProps) | ||||||||||||
2301 | { | ||||||||||||
2302 | const OString &rKey = prop.first; | ||||||||||||
2303 | const OUString &rValue = prop.second; | ||||||||||||
2304 | pWindow->set_property(rKey, rValue); | ||||||||||||
2305 | } | ||||||||||||
2306 | } | ||||||||||||
2307 | |||||||||||||
2308 | OUString convertMnemonicMarkup(const OUString &rIn) | ||||||||||||
2309 | { | ||||||||||||
2310 | OUStringBuffer aRet(rIn); | ||||||||||||
2311 | for (sal_Int32 nI = 0; nI < aRet.getLength(); ++nI) | ||||||||||||
2312 | { | ||||||||||||
2313 | if (aRet[nI] == '_' && nI+1 < aRet.getLength()) | ||||||||||||
2314 | { | ||||||||||||
2315 | if (aRet[nI+1] != '_') | ||||||||||||
2316 | aRet[nI] = MNEMONIC_CHARu'~'; | ||||||||||||
2317 | else | ||||||||||||
2318 | aRet.remove(nI, 1); | ||||||||||||
2319 | ++nI; | ||||||||||||
2320 | } | ||||||||||||
2321 | } | ||||||||||||
2322 | return aRet.makeStringAndClear(); | ||||||||||||
2323 | } | ||||||||||||
2324 | |||||||||||||
2325 | OUString extractCustomProperty(VclBuilder::stringmap &rMap) | ||||||||||||
2326 | { | ||||||||||||
2327 | OUString sCustomProperty; | ||||||||||||
2328 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("customproperty")); | ||||||||||||
2329 | if (aFind != rMap.end()) | ||||||||||||
2330 | { | ||||||||||||
2331 | sCustomProperty = aFind->second; | ||||||||||||
2332 | rMap.erase(aFind); | ||||||||||||
2333 | } | ||||||||||||
2334 | return sCustomProperty; | ||||||||||||
2335 | } | ||||||||||||
2336 | |||||||||||||
2337 | void ensureDefaultWidthChars(VclBuilder::stringmap &rMap) | ||||||||||||
2338 | { | ||||||||||||
2339 | OString sWidthChars("width-chars"); | ||||||||||||
2340 | VclBuilder::stringmap::iterator aFind = rMap.find(sWidthChars); | ||||||||||||
2341 | if (aFind == rMap.end()) | ||||||||||||
2342 | rMap[sWidthChars] = "25"; | ||||||||||||
2343 | } | ||||||||||||
2344 | |||||||||||||
2345 | bool extractDropdown(VclBuilder::stringmap &rMap) | ||||||||||||
2346 | { | ||||||||||||
2347 | bool bDropdown = true; | ||||||||||||
2348 | VclBuilder::stringmap::iterator aFind = rMap.find(OString("dropdown")); | ||||||||||||
2349 | if (aFind != rMap.end()) | ||||||||||||
2350 | { | ||||||||||||
2351 | bDropdown = toBool(aFind->second); | ||||||||||||
2352 | rMap.erase(aFind); | ||||||||||||
2353 | } | ||||||||||||
2354 | return bDropdown; | ||||||||||||
2355 | } | ||||||||||||
2356 | |||||||||||||
2357 | void reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition) | ||||||||||||
2358 | { | ||||||||||||
2359 | WindowImpl *pWindowImpl = rWindow.ImplGetWindowImpl(); | ||||||||||||
2360 | if (pWindowImpl->mpParent != pWindowImpl->mpRealParent) | ||||||||||||
2361 | { | ||||||||||||
2362 | assert(pWindowImpl->mpBorderWindow == pWindowImpl->mpParent)(static_cast <bool> (pWindowImpl->mpBorderWindow == pWindowImpl ->mpParent) ? void (0) : __assert_fail ("pWindowImpl->mpBorderWindow == pWindowImpl->mpParent" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 2362, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
2363 | assert(pWindowImpl->mpBorderWindow->ImplGetWindowImpl()->mpParent == pWindowImpl->mpRealParent)(static_cast <bool> (pWindowImpl->mpBorderWindow-> ImplGetWindowImpl()->mpParent == pWindowImpl->mpRealParent ) ? void (0) : __assert_fail ("pWindowImpl->mpBorderWindow->ImplGetWindowImpl()->mpParent == pWindowImpl->mpRealParent" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 2363, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
2364 | reorderWithinParent(*pWindowImpl->mpBorderWindow, nNewPosition); | ||||||||||||
2365 | return; | ||||||||||||
2366 | } | ||||||||||||
2367 | rWindow.reorderWithinParent(nNewPosition); | ||||||||||||
2368 | } | ||||||||||||
2369 | |||||||||||||
2370 | void reorderWithinParent(std::vector<vcl::Window*>& rChilds, bool bIsButtonBox) | ||||||||||||
2371 | { | ||||||||||||
2372 | for (size_t i = 0; i < rChilds.size(); ++i) | ||||||||||||
2373 | { | ||||||||||||
2374 | reorderWithinParent(*rChilds[i], i); | ||||||||||||
2375 | |||||||||||||
2376 | if (!bIsButtonBox) | ||||||||||||
2377 | continue; | ||||||||||||
2378 | |||||||||||||
2379 | //The first member of the group for legacy code needs WB_GROUP set and the | ||||||||||||
2380 | //others not | ||||||||||||
2381 | WinBits nBits = rChilds[i]->GetStyle(); | ||||||||||||
2382 | nBits &= ~WB_GROUP; | ||||||||||||
2383 | if (i == 0) | ||||||||||||
2384 | nBits |= WB_GROUP; | ||||||||||||
2385 | rChilds[i]->SetStyle(nBits); | ||||||||||||
2386 | } | ||||||||||||
2387 | } | ||||||||||||
2388 | |||||||||||||
2389 | sal_Int16 getRoleFromName(const OString& roleName) | ||||||||||||
2390 | { | ||||||||||||
2391 | using namespace com::sun::star::accessibility; | ||||||||||||
2392 | |||||||||||||
2393 | static const std::unordered_map<OString, sal_Int16> aAtkRoleToAccessibleRole = { | ||||||||||||
2394 | /* This is in atkobject.h's AtkRole order */ | ||||||||||||
2395 | { "invalid", AccessibleRole::UNKNOWN }, | ||||||||||||
2396 | { "accelerator label", AccessibleRole::UNKNOWN }, | ||||||||||||
2397 | { "alert", AccessibleRole::ALERT }, | ||||||||||||
2398 | { "animation", AccessibleRole::UNKNOWN }, | ||||||||||||
2399 | { "arrow", AccessibleRole::UNKNOWN }, | ||||||||||||
2400 | { "calendar", AccessibleRole::UNKNOWN }, | ||||||||||||
2401 | { "canvas", AccessibleRole::CANVAS }, | ||||||||||||
2402 | { "check box", AccessibleRole::CHECK_BOX }, | ||||||||||||
2403 | { "check menu item", AccessibleRole::CHECK_MENU_ITEM }, | ||||||||||||
2404 | { "color chooser", AccessibleRole::COLOR_CHOOSER }, | ||||||||||||
2405 | { "column header", AccessibleRole::COLUMN_HEADER }, | ||||||||||||
2406 | { "combo box", AccessibleRole::COMBO_BOX }, | ||||||||||||
2407 | { "date editor", AccessibleRole::DATE_EDITOR }, | ||||||||||||
2408 | { "desktop icon", AccessibleRole::DESKTOP_ICON }, | ||||||||||||
2409 | { "desktop frame", AccessibleRole::DESKTOP_PANE }, // ? | ||||||||||||
2410 | { "dial", AccessibleRole::UNKNOWN }, | ||||||||||||
2411 | { "dialog", AccessibleRole::DIALOG }, | ||||||||||||
2412 | { "directory pane", AccessibleRole::DIRECTORY_PANE }, | ||||||||||||
2413 | { "drawing area", AccessibleRole::UNKNOWN }, | ||||||||||||
2414 | { "file chooser", AccessibleRole::FILE_CHOOSER }, | ||||||||||||
2415 | { "filler", AccessibleRole::FILLER }, | ||||||||||||
2416 | { "font chooser", AccessibleRole::FONT_CHOOSER }, | ||||||||||||
2417 | { "frame", AccessibleRole::FRAME }, | ||||||||||||
2418 | { "glass pane", AccessibleRole::GLASS_PANE }, | ||||||||||||
2419 | { "html container", AccessibleRole::UNKNOWN }, | ||||||||||||
2420 | { "icon", AccessibleRole::ICON }, | ||||||||||||
2421 | { "image", AccessibleRole::GRAPHIC }, | ||||||||||||
2422 | { "internal frame", AccessibleRole::INTERNAL_FRAME }, | ||||||||||||
2423 | { "label", AccessibleRole::LABEL }, | ||||||||||||
2424 | { "layered pane", AccessibleRole::LAYERED_PANE }, | ||||||||||||
2425 | { "list", AccessibleRole::LIST }, | ||||||||||||
2426 | { "list item", AccessibleRole::LIST_ITEM }, | ||||||||||||
2427 | { "menu", AccessibleRole::MENU }, | ||||||||||||
2428 | { "menu bar", AccessibleRole::MENU_BAR }, | ||||||||||||
2429 | { "menu item", AccessibleRole::MENU_ITEM }, | ||||||||||||
2430 | { "option pane", AccessibleRole::OPTION_PANE }, | ||||||||||||
2431 | { "page tab", AccessibleRole::PAGE_TAB }, | ||||||||||||
2432 | { "page tab list", AccessibleRole::PAGE_TAB_LIST }, | ||||||||||||
2433 | { "panel", AccessibleRole::PANEL }, // or SHAPE or TEXT_FRAME ? | ||||||||||||
2434 | { "password text", AccessibleRole::PASSWORD_TEXT }, | ||||||||||||
2435 | { "popup menu", AccessibleRole::POPUP_MENU }, | ||||||||||||
2436 | { "progress bar", AccessibleRole::PROGRESS_BAR }, | ||||||||||||
2437 | { "push button", AccessibleRole::PUSH_BUTTON }, // or BUTTON_DROPDOWN or BUTTON_MENU | ||||||||||||
2438 | { "radio button", AccessibleRole::RADIO_BUTTON }, | ||||||||||||
2439 | { "radio menu item", AccessibleRole::RADIO_MENU_ITEM }, | ||||||||||||
2440 | { "root pane", AccessibleRole::ROOT_PANE }, | ||||||||||||
2441 | { "row header", AccessibleRole::ROW_HEADER }, | ||||||||||||
2442 | { "scroll bar", AccessibleRole::SCROLL_BAR }, | ||||||||||||
2443 | { "scroll pane", AccessibleRole::SCROLL_PANE }, | ||||||||||||
2444 | { "separator", AccessibleRole::SEPARATOR }, | ||||||||||||
2445 | { "slider", AccessibleRole::SLIDER }, | ||||||||||||
2446 | { "split pane", AccessibleRole::SPLIT_PANE }, | ||||||||||||
2447 | { "spin button", AccessibleRole::SPIN_BOX }, // ? | ||||||||||||
2448 | { "statusbar", AccessibleRole::STATUS_BAR }, | ||||||||||||
2449 | { "table", AccessibleRole::TABLE }, | ||||||||||||
2450 | { "table cell", AccessibleRole::TABLE_CELL }, | ||||||||||||
2451 | { "table column header", AccessibleRole::COLUMN_HEADER }, // approximate | ||||||||||||
2452 | { "table row header", AccessibleRole::ROW_HEADER }, // approximate | ||||||||||||
2453 | { "tear off menu item", AccessibleRole::UNKNOWN }, | ||||||||||||
2454 | { "terminal", AccessibleRole::UNKNOWN }, | ||||||||||||
2455 | { "text", AccessibleRole::TEXT }, | ||||||||||||
2456 | { "toggle button", AccessibleRole::TOGGLE_BUTTON }, | ||||||||||||
2457 | { "tool bar", AccessibleRole::TOOL_BAR }, | ||||||||||||
2458 | { "tool tip", AccessibleRole::TOOL_TIP }, | ||||||||||||
2459 | { "tree", AccessibleRole::TREE }, | ||||||||||||
2460 | { "tree table", AccessibleRole::TREE_TABLE }, | ||||||||||||
2461 | { "unknown", AccessibleRole::UNKNOWN }, | ||||||||||||
2462 | { "viewport", AccessibleRole::VIEW_PORT }, | ||||||||||||
2463 | { "window", AccessibleRole::WINDOW }, | ||||||||||||
2464 | { "header", AccessibleRole::HEADER }, | ||||||||||||
2465 | { "footer", AccessibleRole::FOOTER }, | ||||||||||||
2466 | { "paragraph", AccessibleRole::PARAGRAPH }, | ||||||||||||
2467 | { "ruler", AccessibleRole::RULER }, | ||||||||||||
2468 | { "application", AccessibleRole::UNKNOWN }, | ||||||||||||
2469 | { "autocomplete", AccessibleRole::UNKNOWN }, | ||||||||||||
2470 | { "edit bar", AccessibleRole::EDIT_BAR }, | ||||||||||||
2471 | { "embedded", AccessibleRole::EMBEDDED_OBJECT }, | ||||||||||||
2472 | { "entry", AccessibleRole::UNKNOWN }, | ||||||||||||
2473 | { "chart", AccessibleRole::CHART }, | ||||||||||||
2474 | { "caption", AccessibleRole::CAPTION }, | ||||||||||||
2475 | { "document frame", AccessibleRole::DOCUMENT }, | ||||||||||||
2476 | { "heading", AccessibleRole::HEADING }, | ||||||||||||
2477 | { "page", AccessibleRole::PAGE }, | ||||||||||||
2478 | { "section", AccessibleRole::SECTION }, | ||||||||||||
2479 | { "redundant object", AccessibleRole::UNKNOWN }, | ||||||||||||
2480 | { "form", AccessibleRole::FORM }, | ||||||||||||
2481 | { "link", AccessibleRole::HYPER_LINK }, | ||||||||||||
2482 | { "input method window", AccessibleRole::UNKNOWN }, | ||||||||||||
2483 | { "table row", AccessibleRole::UNKNOWN }, | ||||||||||||
2484 | { "tree item", AccessibleRole::TREE_ITEM }, | ||||||||||||
2485 | { "document spreadsheet", AccessibleRole::DOCUMENT_SPREADSHEET }, | ||||||||||||
2486 | { "document presentation", AccessibleRole::DOCUMENT_PRESENTATION }, | ||||||||||||
2487 | { "document text", AccessibleRole::DOCUMENT_TEXT }, | ||||||||||||
2488 | { "document web", AccessibleRole::DOCUMENT }, // approximate | ||||||||||||
2489 | { "document email", AccessibleRole::DOCUMENT }, // approximate | ||||||||||||
2490 | { "comment", AccessibleRole::COMMENT }, // or NOTE or END_NOTE or FOOTNOTE or SCROLL_PANE | ||||||||||||
2491 | { "list box", AccessibleRole::UNKNOWN }, | ||||||||||||
2492 | { "grouping", AccessibleRole::GROUP_BOX }, | ||||||||||||
2493 | { "image map", AccessibleRole::IMAGE_MAP }, | ||||||||||||
2494 | { "notification", AccessibleRole::UNKNOWN }, | ||||||||||||
2495 | { "info bar", AccessibleRole::UNKNOWN }, | ||||||||||||
2496 | { "level bar", AccessibleRole::UNKNOWN }, | ||||||||||||
2497 | { "title bar", AccessibleRole::UNKNOWN }, | ||||||||||||
2498 | { "block quote", AccessibleRole::UNKNOWN }, | ||||||||||||
2499 | { "audio", AccessibleRole::UNKNOWN }, | ||||||||||||
2500 | { "video", AccessibleRole::UNKNOWN }, | ||||||||||||
2501 | { "definition", AccessibleRole::UNKNOWN }, | ||||||||||||
2502 | { "article", AccessibleRole::UNKNOWN }, | ||||||||||||
2503 | { "landmark", AccessibleRole::UNKNOWN }, | ||||||||||||
2504 | { "log", AccessibleRole::UNKNOWN }, | ||||||||||||
2505 | { "marquee", AccessibleRole::UNKNOWN }, | ||||||||||||
2506 | { "math", AccessibleRole::UNKNOWN }, | ||||||||||||
2507 | { "rating", AccessibleRole::UNKNOWN }, | ||||||||||||
2508 | { "timer", AccessibleRole::UNKNOWN }, | ||||||||||||
2509 | { "description list", AccessibleRole::UNKNOWN }, | ||||||||||||
2510 | { "description term", AccessibleRole::UNKNOWN }, | ||||||||||||
2511 | { "description value", AccessibleRole::UNKNOWN }, | ||||||||||||
2512 | { "static", AccessibleRole::STATIC }, | ||||||||||||
2513 | { "math fraction", AccessibleRole::UNKNOWN }, | ||||||||||||
2514 | { "math root", AccessibleRole::UNKNOWN }, | ||||||||||||
2515 | { "subscript", AccessibleRole::UNKNOWN }, | ||||||||||||
2516 | { "superscript", AccessibleRole::UNKNOWN }, | ||||||||||||
2517 | { "footnote", AccessibleRole::FOOTNOTE }, | ||||||||||||
2518 | }; | ||||||||||||
2519 | |||||||||||||
2520 | auto it = aAtkRoleToAccessibleRole.find(roleName); | ||||||||||||
2521 | if (it == aAtkRoleToAccessibleRole.end()) | ||||||||||||
2522 | return AccessibleRole::UNKNOWN; | ||||||||||||
2523 | return it->second; | ||||||||||||
2524 | } | ||||||||||||
2525 | } | ||||||||||||
2526 | |||||||||||||
2527 | VclPtr<vcl::Window> VclBuilder::insertObject(vcl::Window *pParent, const OString &rClass, | ||||||||||||
2528 | const OString &rID, stringmap &rProps, stringmap &rPango, stringmap &rAtk) | ||||||||||||
2529 | { | ||||||||||||
2530 | VclPtr<vcl::Window> pCurrentChild; | ||||||||||||
2531 | |||||||||||||
2532 | if (m_pParent && !isConsideredGtkPseudo(m_pParent) && !m_sID.isEmpty() && rID == m_sID) | ||||||||||||
2533 | { | ||||||||||||
2534 | pCurrentChild = m_pParent; | ||||||||||||
2535 | |||||||||||||
2536 | //toplevels default to resizable and apparently you can't change them | ||||||||||||
2537 | //afterwards, so we need to wait until now before we can truly | ||||||||||||
2538 | //initialize the dialog. | ||||||||||||
2539 | if (pParent && pParent->IsSystemWindow()) | ||||||||||||
2540 | { | ||||||||||||
2541 | SystemWindow *pSysWin = static_cast<SystemWindow*>(pCurrentChild.get()); | ||||||||||||
2542 | pSysWin->doDeferredInit(extractDeferredBits(rProps)); | ||||||||||||
2543 | m_bToplevelHasDeferredInit = false; | ||||||||||||
2544 | } | ||||||||||||
2545 | else if (pParent && pParent->IsDockingWindow()) | ||||||||||||
2546 | { | ||||||||||||
2547 | DockingWindow *pDockWin = static_cast<DockingWindow*>(pCurrentChild.get()); | ||||||||||||
2548 | pDockWin->doDeferredInit(extractDeferredBits(rProps)); | ||||||||||||
2549 | m_bToplevelHasDeferredInit = false; | ||||||||||||
2550 | } | ||||||||||||
2551 | |||||||||||||
2552 | if (pCurrentChild->GetHelpId().isEmpty()) | ||||||||||||
2553 | { | ||||||||||||
2554 | pCurrentChild->SetHelpId(m_sHelpRoot + m_sID); | ||||||||||||
2555 | SAL_INFO("vcl.builder", "for toplevel dialog " << this << " " <<do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild->GetHelpId()) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2556" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild ->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild ->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2556" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild ->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2556" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild ->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild ->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2556" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false) | ||||||||||||
2556 | rID << ", set helpid " << pCurrentChild->GetHelpId())do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild->GetHelpId()) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2556" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild ->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild ->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2556" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild ->GetHelpId()) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2556" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild ->GetHelpId()), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "for toplevel dialog " << this << " " << rID << ", set helpid " << pCurrentChild ->GetHelpId(); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2556" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
2557 | } | ||||||||||||
2558 | m_bToplevelParentFound = true; | ||||||||||||
2559 | } | ||||||||||||
2560 | else | ||||||||||||
2561 | { | ||||||||||||
2562 | //if we're being inserting under a toplevel dialog whose init is | ||||||||||||
2563 | //deferred due to waiting to encounter it in this .ui, and it hasn't | ||||||||||||
2564 | //been seen yet, then make unattached widgets parent-less toplevels | ||||||||||||
2565 | if (pParent == m_pParent.get() && m_bToplevelHasDeferredInit) | ||||||||||||
2566 | pParent = nullptr; | ||||||||||||
2567 | pCurrentChild = makeObject(pParent, rClass, rID, rProps); | ||||||||||||
2568 | } | ||||||||||||
2569 | |||||||||||||
2570 | if (pCurrentChild) | ||||||||||||
2571 | { | ||||||||||||
2572 | pCurrentChild->set_id(OStringToOUString(rID, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))); | ||||||||||||
2573 | if (pCurrentChild == m_pParent.get() && m_bToplevelHasDeferredProperties) | ||||||||||||
2574 | m_aDeferredProperties = rProps; | ||||||||||||
2575 | else | ||||||||||||
2576 | BuilderUtils::set_properties(pCurrentChild, rProps); | ||||||||||||
2577 | |||||||||||||
2578 | for (auto const& elem : rPango) | ||||||||||||
2579 | { | ||||||||||||
2580 | const OString &rKey = elem.first; | ||||||||||||
2581 | const OUString &rValue = elem.second; | ||||||||||||
2582 | pCurrentChild->set_font_attribute(rKey, rValue); | ||||||||||||
2583 | } | ||||||||||||
2584 | |||||||||||||
2585 | m_pParserState->m_aAtkInfo[pCurrentChild] = rAtk; | ||||||||||||
2586 | } | ||||||||||||
2587 | |||||||||||||
2588 | rProps.clear(); | ||||||||||||
2589 | rPango.clear(); | ||||||||||||
2590 | rAtk.clear(); | ||||||||||||
2591 | |||||||||||||
2592 | if (!pCurrentChild) | ||||||||||||
2593 | { | ||||||||||||
2594 | bool bToolbarParent = (pParent && pParent->GetType() == WindowType::TOOLBOX); | ||||||||||||
2595 | pCurrentChild = (m_aChildren.empty() || bToolbarParent) ? pParent : m_aChildren.back().m_pWindow.get(); | ||||||||||||
2596 | } | ||||||||||||
2597 | return pCurrentChild; | ||||||||||||
2598 | } | ||||||||||||
2599 | |||||||||||||
2600 | void VclBuilder::handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader) | ||||||||||||
2601 | { | ||||||||||||
2602 | TabControl *pTabControl = pParent && pParent->GetType() == WindowType::TABCONTROL ? | ||||||||||||
2603 | static_cast<TabControl*>(pParent) : nullptr; | ||||||||||||
2604 | |||||||||||||
2605 | std::vector<OString> sIDs; | ||||||||||||
2606 | |||||||||||||
2607 | int nLevel = 1; | ||||||||||||
2608 | stringmap aProperties; | ||||||||||||
2609 | stringmap aAtkProperties; | ||||||||||||
2610 | std::vector<vcl::EnumContext::Context> context; | ||||||||||||
2611 | |||||||||||||
2612 | while(true) | ||||||||||||
2613 | { | ||||||||||||
2614 | xmlreader::Span name; | ||||||||||||
2615 | int nsId; | ||||||||||||
2616 | |||||||||||||
2617 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
2618 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
2619 | |||||||||||||
2620 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
2621 | { | ||||||||||||
2622 | ++nLevel; | ||||||||||||
2623 | if (name == "object") | ||||||||||||
2624 | { | ||||||||||||
2625 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
2626 | { | ||||||||||||
2627 | if (name == "id") | ||||||||||||
2628 | { | ||||||||||||
2629 | name = reader.getAttributeValue(false); | ||||||||||||
2630 | OString sID(name.begin, name.length); | ||||||||||||
2631 | sal_Int32 nDelim = sID.indexOf(':'); | ||||||||||||
2632 | if (nDelim != -1) | ||||||||||||
2633 | { | ||||||||||||
2634 | OString sPattern = sID.copy(nDelim+1); | ||||||||||||
2635 | aProperties[OString("customproperty")] = OUString::fromUtf8(sPattern); | ||||||||||||
2636 | sID = sID.copy(0, nDelim); | ||||||||||||
2637 | } | ||||||||||||
2638 | sIDs.push_back(sID); | ||||||||||||
2639 | } | ||||||||||||
2640 | } | ||||||||||||
2641 | } | ||||||||||||
2642 | else if (name == "style") | ||||||||||||
2643 | { | ||||||||||||
2644 | int nPriority = 0; | ||||||||||||
2645 | context = handleStyle(reader, nPriority); | ||||||||||||
2646 | --nLevel; | ||||||||||||
2647 | } | ||||||||||||
2648 | else if (name == "property") | ||||||||||||
2649 | collectProperty(reader, aProperties); | ||||||||||||
2650 | else if (pTabControl && name == "child") | ||||||||||||
2651 | { | ||||||||||||
2652 | // just to collect the atk properties (if any) for the label | ||||||||||||
2653 | handleChild(nullptr, &aAtkProperties, reader); | ||||||||||||
2654 | --nLevel; | ||||||||||||
2655 | } | ||||||||||||
2656 | } | ||||||||||||
2657 | |||||||||||||
2658 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
2659 | --nLevel; | ||||||||||||
2660 | |||||||||||||
2661 | if (!nLevel) | ||||||||||||
2662 | break; | ||||||||||||
2663 | |||||||||||||
2664 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
2665 | break; | ||||||||||||
2666 | } | ||||||||||||
2667 | |||||||||||||
2668 | if (!pParent) | ||||||||||||
2669 | return; | ||||||||||||
2670 | |||||||||||||
2671 | VerticalTabControl *pVerticalTabControl = pParent->GetType() == WindowType::VERTICALTABCONTROL ? | ||||||||||||
2672 | static_cast<VerticalTabControl*>(pParent) : nullptr; | ||||||||||||
2673 | assert(pTabControl || pVerticalTabControl)(static_cast <bool> (pTabControl || pVerticalTabControl ) ? void (0) : __assert_fail ("pTabControl || pVerticalTabControl" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 2673, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
2674 | VclBuilder::stringmap::iterator aFind = aProperties.find(OString("label")); | ||||||||||||
2675 | if (aFind != aProperties.end()) | ||||||||||||
2676 | { | ||||||||||||
2677 | if (pTabControl) | ||||||||||||
2678 | { | ||||||||||||
2679 | sal_uInt16 nPageId = pTabControl->GetCurPageId(); | ||||||||||||
2680 | pTabControl->SetPageText(nPageId, aFind->second); | ||||||||||||
2681 | pTabControl->SetPageName(nPageId, sIDs.back()); | ||||||||||||
2682 | if (!context.empty()) | ||||||||||||
2683 | { | ||||||||||||
2684 | TabPage* pPage = pTabControl->GetTabPage(nPageId); | ||||||||||||
2685 | pPage->SetContext(context); | ||||||||||||
2686 | } | ||||||||||||
2687 | |||||||||||||
2688 | for (auto const& prop : aAtkProperties) | ||||||||||||
2689 | { | ||||||||||||
2690 | const OString &rKey = prop.first; | ||||||||||||
2691 | const OUString &rValue = prop.second; | ||||||||||||
2692 | |||||||||||||
2693 | if (rKey == "AtkObject::accessible-name") | ||||||||||||
2694 | pTabControl->SetAccessibleName(nPageId, rValue); | ||||||||||||
2695 | else if (rKey == "AtkObject::accessible-description") | ||||||||||||
2696 | pTabControl->SetAccessibleDescription(nPageId, rValue); | ||||||||||||
2697 | else | ||||||||||||
2698 | SAL_INFO("vcl.builder", "unhandled atk property: " << rKey)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled atk property: " << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2698" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled atk property: " << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled atk property: " << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2698" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled atk property: " << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2698" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled atk property: " << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled atk property: " << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "2698" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
2699 | } | ||||||||||||
2700 | |||||||||||||
2701 | } | ||||||||||||
2702 | else | ||||||||||||
2703 | { | ||||||||||||
2704 | OUString sLabel(aFind->second); | ||||||||||||
2705 | OUString sIconName(extractIconName(aProperties)); | ||||||||||||
2706 | OUString sTooltip(extractTooltipText(aProperties)); | ||||||||||||
2707 | pVerticalTabControl->InsertPage(sIDs.front(), sLabel, FixedImage::loadThemeImage(sIconName), sTooltip, | ||||||||||||
2708 | pVerticalTabControl->GetPageParent()->GetWindow(GetWindowType::LastChild)); | ||||||||||||
2709 | } | ||||||||||||
2710 | } | ||||||||||||
2711 | else | ||||||||||||
2712 | { | ||||||||||||
2713 | if (pTabControl) | ||||||||||||
2714 | pTabControl->RemovePage(pTabControl->GetCurPageId()); | ||||||||||||
2715 | } | ||||||||||||
2716 | } | ||||||||||||
2717 | |||||||||||||
2718 | //so that tabbing between controls goes in a visually sensible sequence | ||||||||||||
2719 | //we sort these into a best-tab-order sequence | ||||||||||||
2720 | bool VclBuilder::sortIntoBestTabTraversalOrder::operator()(const vcl::Window *pA, const vcl::Window *pB) const | ||||||||||||
2721 | { | ||||||||||||
2722 | //sort child order within parent list by grid position | ||||||||||||
2723 | sal_Int32 nTopA = pA->get_grid_top_attach(); | ||||||||||||
2724 | sal_Int32 nTopB = pB->get_grid_top_attach(); | ||||||||||||
2725 | if (nTopA < nTopB) | ||||||||||||
2726 | return true; | ||||||||||||
2727 | if (nTopA > nTopB) | ||||||||||||
2728 | return false; | ||||||||||||
2729 | sal_Int32 nLeftA = pA->get_grid_left_attach(); | ||||||||||||
2730 | sal_Int32 nLeftB = pB->get_grid_left_attach(); | ||||||||||||
2731 | if (nLeftA < nLeftB) | ||||||||||||
2732 | return true; | ||||||||||||
2733 | if (nLeftA > nLeftB) | ||||||||||||
2734 | return false; | ||||||||||||
2735 | //sort into two groups of pack start and pack end | ||||||||||||
2736 | VclPackType ePackA = pA->get_pack_type(); | ||||||||||||
2737 | VclPackType ePackB = pB->get_pack_type(); | ||||||||||||
2738 | if (ePackA < ePackB) | ||||||||||||
2739 | return true; | ||||||||||||
2740 | if (ePackA > ePackB) | ||||||||||||
2741 | return false; | ||||||||||||
2742 | bool bVerticalContainer = m_pBuilder->get_window_packing_data(pA->GetParent()).m_bVerticalOrient; | ||||||||||||
2743 | bool bPackA = pA->get_secondary(); | ||||||||||||
2744 | bool bPackB = pB->get_secondary(); | ||||||||||||
2745 | if (!bVerticalContainer) | ||||||||||||
2746 | { | ||||||||||||
2747 | //for horizontal boxes group secondaries before primaries | ||||||||||||
2748 | if (bPackA > bPackB) | ||||||||||||
2749 | return true; | ||||||||||||
2750 | if (bPackA < bPackB) | ||||||||||||
2751 | return false; | ||||||||||||
2752 | } | ||||||||||||
2753 | else | ||||||||||||
2754 | { | ||||||||||||
2755 | //for vertical boxes group secondaries after primaries | ||||||||||||
2756 | if (bPackA < bPackB) | ||||||||||||
2757 | return true; | ||||||||||||
2758 | if (bPackA > bPackB) | ||||||||||||
2759 | return false; | ||||||||||||
2760 | } | ||||||||||||
2761 | //honour relative box positions with pack group, (numerical order is reversed | ||||||||||||
2762 | //for VclPackType::End, they are packed from the end back, but here we need | ||||||||||||
2763 | //them in visual layout order so that tabbing works as expected) | ||||||||||||
2764 | sal_Int32 nPackA = m_pBuilder->get_window_packing_data(pA).m_nPosition; | ||||||||||||
2765 | sal_Int32 nPackB = m_pBuilder->get_window_packing_data(pB).m_nPosition; | ||||||||||||
2766 | if (nPackA < nPackB) | ||||||||||||
2767 | return ePackA == VclPackType::Start; | ||||||||||||
2768 | if (nPackA > nPackB) | ||||||||||||
2769 | return ePackA != VclPackType::Start; | ||||||||||||
2770 | //sort labels of Frames before body | ||||||||||||
2771 | if (pA->GetParent() == pB->GetParent()) | ||||||||||||
2772 | { | ||||||||||||
2773 | const VclFrame *pFrameParent = dynamic_cast<const VclFrame*>(pA->GetParent()); | ||||||||||||
2774 | if (pFrameParent) | ||||||||||||
2775 | { | ||||||||||||
2776 | const vcl::Window *pLabel = pFrameParent->get_label_widget(); | ||||||||||||
2777 | int nFramePosA = (pA == pLabel) ? 0 : 1; | ||||||||||||
2778 | int nFramePosB = (pB == pLabel) ? 0 : 1; | ||||||||||||
2779 | return nFramePosA < nFramePosB; | ||||||||||||
2780 | } | ||||||||||||
2781 | } | ||||||||||||
2782 | return false; | ||||||||||||
2783 | } | ||||||||||||
2784 | |||||||||||||
2785 | void VclBuilder::handleChild(vcl::Window *pParent, stringmap* pAtkProps, xmlreader::XmlReader &reader) | ||||||||||||
2786 | { | ||||||||||||
2787 | vcl::Window *pCurrentChild = nullptr; | ||||||||||||
2788 | |||||||||||||
2789 | xmlreader::Span name; | ||||||||||||
2790 | int nsId; | ||||||||||||
2791 | OString sType, sInternalChild; | ||||||||||||
2792 | |||||||||||||
2793 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
2794 | { | ||||||||||||
2795 | if (name == "type") | ||||||||||||
2796 | { | ||||||||||||
2797 | name = reader.getAttributeValue(false); | ||||||||||||
2798 | sType = OString(name.begin, name.length); | ||||||||||||
2799 | } | ||||||||||||
2800 | else if (name == "internal-child") | ||||||||||||
2801 | { | ||||||||||||
2802 | name = reader.getAttributeValue(false); | ||||||||||||
2803 | sInternalChild = OString(name.begin, name.length); | ||||||||||||
2804 | } | ||||||||||||
2805 | } | ||||||||||||
2806 | |||||||||||||
2807 | if (sType == "tab") | ||||||||||||
2808 | { | ||||||||||||
2809 | handleTabChild(pParent, reader); | ||||||||||||
2810 | return; | ||||||||||||
2811 | } | ||||||||||||
2812 | |||||||||||||
2813 | int nLevel = 1; | ||||||||||||
2814 | while(true) | ||||||||||||
2815 | { | ||||||||||||
2816 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
2817 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
2818 | |||||||||||||
2819 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
2820 | { | ||||||||||||
2821 | if (name == "object" || name == "placeholder") | ||||||||||||
2822 | { | ||||||||||||
2823 | pCurrentChild = handleObject(pParent, pAtkProps, reader).get(); | ||||||||||||
2824 | |||||||||||||
2825 | bool bObjectInserted = pCurrentChild
| ||||||||||||
2826 | |||||||||||||
2827 | if (bObjectInserted
| ||||||||||||
2828 | { | ||||||||||||
2829 | //Internal-children default in glade to not having their visible bits set | ||||||||||||
2830 | //even though they are visible (generally anyway) | ||||||||||||
2831 | if (!sInternalChild.isEmpty()) | ||||||||||||
2832 | pCurrentChild->Show(); | ||||||||||||
2833 | |||||||||||||
2834 | //Select the first page if it's a notebook | ||||||||||||
2835 | if (pCurrentChild->GetType() == WindowType::TABCONTROL) | ||||||||||||
| |||||||||||||
2836 | { | ||||||||||||
2837 | TabControl *pTabControl = static_cast<TabControl*>(pCurrentChild); | ||||||||||||
2838 | pTabControl->SetCurPageId(pTabControl->GetPageId(0)); | ||||||||||||
2839 | |||||||||||||
2840 | //To-Do add reorder capability to the TabControl | ||||||||||||
2841 | } | ||||||||||||
2842 | else | ||||||||||||
2843 | { | ||||||||||||
2844 | // We want to sort labels before contents of frames | ||||||||||||
2845 | // for keyboard traversal, especially if there | ||||||||||||
2846 | // are multiple widgets using the same mnemonic | ||||||||||||
2847 | if (sType == "label") | ||||||||||||
2848 | { | ||||||||||||
2849 | if (VclFrame *pFrameParent = dynamic_cast<VclFrame*>(pParent)) | ||||||||||||
2850 | pFrameParent->designate_label(pCurrentChild); | ||||||||||||
2851 | } | ||||||||||||
2852 | if (sInternalChild.startsWith("vbox") || sInternalChild.startsWith("messagedialog-vbox")) | ||||||||||||
2853 | { | ||||||||||||
2854 | if (Dialog *pBoxParent = dynamic_cast<Dialog*>(pParent)) | ||||||||||||
2855 | pBoxParent->set_content_area(static_cast<VclBox*>(pCurrentChild)); // FIXME-VCLPTR | ||||||||||||
2856 | } | ||||||||||||
2857 | else if (sInternalChild.startsWith("action_area") || sInternalChild.startsWith("messagedialog-action_area")) | ||||||||||||
2858 | { | ||||||||||||
2859 | vcl::Window *pContentArea = pCurrentChild->GetParent(); | ||||||||||||
2860 | if (Dialog *pBoxParent = dynamic_cast<Dialog*>(pContentArea ? pContentArea->GetParent() : nullptr)) | ||||||||||||
2861 | { | ||||||||||||
2862 | pBoxParent->set_action_area(static_cast<VclButtonBox*>(pCurrentChild)); // FIXME-VCLPTR | ||||||||||||
2863 | } | ||||||||||||
2864 | } | ||||||||||||
2865 | |||||||||||||
2866 | bool bIsButtonBox = dynamic_cast<VclButtonBox*>(pCurrentChild) != nullptr; | ||||||||||||
2867 | |||||||||||||
2868 | //To-Do make reorder a virtual in Window, move this foo | ||||||||||||
2869 | //there and see above | ||||||||||||
2870 | std::vector<vcl::Window*> aChilds; | ||||||||||||
2871 | for (vcl::Window* pChild = pCurrentChild->GetWindow(GetWindowType::FirstChild); pChild; | ||||||||||||
2872 | pChild = pChild->GetWindow(GetWindowType::Next)) | ||||||||||||
2873 | { | ||||||||||||
2874 | if (bIsButtonBox) | ||||||||||||
2875 | { | ||||||||||||
2876 | if (PushButton* pPushButton = dynamic_cast<PushButton*>(pChild)) | ||||||||||||
2877 | pPushButton->setAction(true); | ||||||||||||
2878 | } | ||||||||||||
2879 | |||||||||||||
2880 | aChilds.push_back(pChild); | ||||||||||||
2881 | } | ||||||||||||
2882 | |||||||||||||
2883 | //sort child order within parent so that tabbing | ||||||||||||
2884 | //between controls goes in a visually sensible sequence | ||||||||||||
2885 | std::stable_sort(aChilds.begin(), aChilds.end(), sortIntoBestTabTraversalOrder(this)); | ||||||||||||
2886 | BuilderUtils::reorderWithinParent(aChilds, bIsButtonBox); | ||||||||||||
2887 | } | ||||||||||||
2888 | } | ||||||||||||
2889 | } | ||||||||||||
2890 | else if (name == "packing") | ||||||||||||
2891 | { | ||||||||||||
2892 | handlePacking(pCurrentChild, pParent, reader); | ||||||||||||
2893 | } | ||||||||||||
2894 | else if (name == "interface") | ||||||||||||
2895 | { | ||||||||||||
2896 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
2897 | { | ||||||||||||
2898 | if (name == "domain") | ||||||||||||
2899 | { | ||||||||||||
2900 | name = reader.getAttributeValue(false); | ||||||||||||
2901 | sType = OString(name.begin, name.length); | ||||||||||||
2902 | m_pParserState->m_aResLocale = Translate::Create(sType.getStr()); | ||||||||||||
2903 | } | ||||||||||||
2904 | } | ||||||||||||
2905 | ++nLevel; | ||||||||||||
2906 | } | ||||||||||||
2907 | else | ||||||||||||
2908 | ++nLevel; | ||||||||||||
2909 | } | ||||||||||||
2910 | |||||||||||||
2911 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
2912 | --nLevel; | ||||||||||||
2913 | |||||||||||||
2914 | if (!nLevel) | ||||||||||||
2915 | break; | ||||||||||||
2916 | |||||||||||||
2917 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
2918 | break; | ||||||||||||
2919 | } | ||||||||||||
2920 | } | ||||||||||||
2921 | |||||||||||||
2922 | void VclBuilder::collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap) | ||||||||||||
2923 | { | ||||||||||||
2924 | xmlreader::Span span; | ||||||||||||
2925 | int nsId; | ||||||||||||
2926 | |||||||||||||
2927 | OString sProperty; | ||||||||||||
2928 | OString sValue; | ||||||||||||
2929 | |||||||||||||
2930 | while (reader.nextAttribute(&nsId, &span)) | ||||||||||||
2931 | { | ||||||||||||
2932 | if (span == "name") | ||||||||||||
2933 | { | ||||||||||||
2934 | span = reader.getAttributeValue(false); | ||||||||||||
2935 | sProperty = OString(span.begin, span.length); | ||||||||||||
2936 | } | ||||||||||||
2937 | else if (span == "value") | ||||||||||||
2938 | { | ||||||||||||
2939 | span = reader.getAttributeValue(false); | ||||||||||||
2940 | sValue = OString(span.begin, span.length); | ||||||||||||
2941 | } | ||||||||||||
2942 | } | ||||||||||||
2943 | |||||||||||||
2944 | if (!sProperty.isEmpty()) | ||||||||||||
2945 | rMap[sProperty] = OUString::fromUtf8(sValue); | ||||||||||||
2946 | } | ||||||||||||
2947 | |||||||||||||
2948 | void VclBuilder::collectAtkRelationAttribute(xmlreader::XmlReader &reader, stringmap &rMap) | ||||||||||||
2949 | { | ||||||||||||
2950 | xmlreader::Span span; | ||||||||||||
2951 | int nsId; | ||||||||||||
2952 | |||||||||||||
2953 | OString sProperty; | ||||||||||||
2954 | OString sValue; | ||||||||||||
2955 | |||||||||||||
2956 | while (reader.nextAttribute(&nsId, &span)) | ||||||||||||
2957 | { | ||||||||||||
2958 | if (span == "type") | ||||||||||||
2959 | { | ||||||||||||
2960 | span = reader.getAttributeValue(false); | ||||||||||||
2961 | sProperty = OString(span.begin, span.length); | ||||||||||||
2962 | } | ||||||||||||
2963 | else if (span == "target") | ||||||||||||
2964 | { | ||||||||||||
2965 | span = reader.getAttributeValue(false); | ||||||||||||
2966 | sValue = OString(span.begin, span.length); | ||||||||||||
2967 | sal_Int32 nDelim = sValue.indexOf(':'); | ||||||||||||
2968 | if (nDelim != -1) | ||||||||||||
2969 | sValue = sValue.copy(0, nDelim); | ||||||||||||
2970 | } | ||||||||||||
2971 | } | ||||||||||||
2972 | |||||||||||||
2973 | if (!sProperty.isEmpty()) | ||||||||||||
2974 | rMap[sProperty] = OUString::fromUtf8(sValue); | ||||||||||||
2975 | } | ||||||||||||
2976 | |||||||||||||
2977 | void VclBuilder::collectAtkRoleAttribute(xmlreader::XmlReader &reader, stringmap &rMap) | ||||||||||||
2978 | { | ||||||||||||
2979 | xmlreader::Span span; | ||||||||||||
2980 | int nsId; | ||||||||||||
2981 | |||||||||||||
2982 | OString sProperty; | ||||||||||||
2983 | |||||||||||||
2984 | while (reader.nextAttribute(&nsId, &span)) | ||||||||||||
2985 | { | ||||||||||||
2986 | if (span == "type") | ||||||||||||
2987 | { | ||||||||||||
2988 | span = reader.getAttributeValue(false); | ||||||||||||
2989 | sProperty = OString(span.begin, span.length); | ||||||||||||
2990 | } | ||||||||||||
2991 | } | ||||||||||||
2992 | |||||||||||||
2993 | if (!sProperty.isEmpty()) | ||||||||||||
2994 | rMap["role"] = OUString::fromUtf8(sProperty); | ||||||||||||
2995 | } | ||||||||||||
2996 | |||||||||||||
2997 | void VclBuilder::handleRow(xmlreader::XmlReader &reader, const OString &rID) | ||||||||||||
2998 | { | ||||||||||||
2999 | int nLevel = 1; | ||||||||||||
3000 | |||||||||||||
3001 | ListStore::row aRow; | ||||||||||||
3002 | |||||||||||||
3003 | while(true) | ||||||||||||
3004 | { | ||||||||||||
3005 | xmlreader::Span name; | ||||||||||||
3006 | int nsId; | ||||||||||||
3007 | |||||||||||||
3008 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3009 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3010 | |||||||||||||
3011 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3012 | break; | ||||||||||||
3013 | |||||||||||||
3014 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3015 | { | ||||||||||||
3016 | ++nLevel; | ||||||||||||
3017 | if (name == "col") | ||||||||||||
3018 | { | ||||||||||||
3019 | bool bTranslated = false; | ||||||||||||
3020 | sal_uInt32 nId = 0; | ||||||||||||
3021 | OString sContext; | ||||||||||||
3022 | |||||||||||||
3023 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
3024 | { | ||||||||||||
3025 | if (name == "id") | ||||||||||||
3026 | { | ||||||||||||
3027 | name = reader.getAttributeValue(false); | ||||||||||||
3028 | nId = OString(name.begin, name.length).toInt32(); | ||||||||||||
3029 | } | ||||||||||||
3030 | else if (nId == 0 && name == "translatable" && reader.getAttributeValue(false) == "yes") | ||||||||||||
3031 | { | ||||||||||||
3032 | bTranslated = true; | ||||||||||||
3033 | } | ||||||||||||
3034 | else if (name == "context") | ||||||||||||
3035 | { | ||||||||||||
3036 | name = reader.getAttributeValue(false); | ||||||||||||
3037 | sContext = OString(name.begin, name.length); | ||||||||||||
3038 | } | ||||||||||||
3039 | } | ||||||||||||
3040 | |||||||||||||
3041 | (void)reader.nextItem( | ||||||||||||
3042 | xmlreader::XmlReader::Text::Raw, &name, &nsId); | ||||||||||||
3043 | |||||||||||||
3044 | OString sValue(name.begin, name.length); | ||||||||||||
3045 | OUString sFinalValue; | ||||||||||||
3046 | if (bTranslated) | ||||||||||||
3047 | { | ||||||||||||
3048 | if (!sContext.isEmpty()) | ||||||||||||
3049 | sValue = sContext + "\004" + sValue; | ||||||||||||
3050 | sFinalValue = Translate::get(sValue.getStr(), m_pParserState->m_aResLocale); | ||||||||||||
3051 | } | ||||||||||||
3052 | else | ||||||||||||
3053 | sFinalValue = OUString::fromUtf8(sValue); | ||||||||||||
3054 | |||||||||||||
3055 | |||||||||||||
3056 | if (aRow.size() < nId+1) | ||||||||||||
3057 | aRow.resize(nId+1); | ||||||||||||
3058 | aRow[nId] = sFinalValue; | ||||||||||||
3059 | } | ||||||||||||
3060 | } | ||||||||||||
3061 | |||||||||||||
3062 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3063 | { | ||||||||||||
3064 | --nLevel; | ||||||||||||
3065 | } | ||||||||||||
3066 | |||||||||||||
3067 | if (!nLevel) | ||||||||||||
3068 | break; | ||||||||||||
3069 | } | ||||||||||||
3070 | |||||||||||||
3071 | m_pParserState->m_aModels[rID].m_aEntries.push_back(aRow); | ||||||||||||
3072 | } | ||||||||||||
3073 | |||||||||||||
3074 | void VclBuilder::handleListStore(xmlreader::XmlReader &reader, const OString &rID, const OString &rClass) | ||||||||||||
3075 | { | ||||||||||||
3076 | int nLevel = 1; | ||||||||||||
3077 | |||||||||||||
3078 | while(true) | ||||||||||||
3079 | { | ||||||||||||
3080 | xmlreader::Span name; | ||||||||||||
3081 | int nsId; | ||||||||||||
3082 | |||||||||||||
3083 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3084 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3085 | |||||||||||||
3086 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3087 | break; | ||||||||||||
3088 | |||||||||||||
3089 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3090 | { | ||||||||||||
3091 | if (name == "row") | ||||||||||||
3092 | { | ||||||||||||
3093 | bool bNotTreeStore = rClass != "GtkTreeStore"; | ||||||||||||
3094 | if (bNotTreeStore) | ||||||||||||
3095 | handleRow(reader, rID); | ||||||||||||
3096 | assert(bNotTreeStore && "gtk, as the time of writing, doesn't support data in GtkTreeStore serialization")(static_cast <bool> (bNotTreeStore && "gtk, as the time of writing, doesn't support data in GtkTreeStore serialization" ) ? void (0) : __assert_fail ("bNotTreeStore && \"gtk, as the time of writing, doesn't support data in GtkTreeStore serialization\"" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 3096, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
3097 | } | ||||||||||||
3098 | else | ||||||||||||
3099 | ++nLevel; | ||||||||||||
3100 | } | ||||||||||||
3101 | |||||||||||||
3102 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3103 | { | ||||||||||||
3104 | --nLevel; | ||||||||||||
3105 | } | ||||||||||||
3106 | |||||||||||||
3107 | if (!nLevel) | ||||||||||||
3108 | break; | ||||||||||||
3109 | } | ||||||||||||
3110 | } | ||||||||||||
3111 | |||||||||||||
3112 | VclBuilder::stringmap VclBuilder::handleAtkObject(xmlreader::XmlReader &reader) | ||||||||||||
3113 | { | ||||||||||||
3114 | int nLevel = 1; | ||||||||||||
3115 | |||||||||||||
3116 | stringmap aProperties; | ||||||||||||
3117 | |||||||||||||
3118 | while (true) | ||||||||||||
3119 | { | ||||||||||||
3120 | xmlreader::Span name; | ||||||||||||
3121 | int nsId; | ||||||||||||
3122 | |||||||||||||
3123 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3124 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3125 | |||||||||||||
3126 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3127 | break; | ||||||||||||
3128 | |||||||||||||
3129 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3130 | { | ||||||||||||
3131 | ++nLevel; | ||||||||||||
3132 | if (name == "property") | ||||||||||||
3133 | collectProperty(reader, aProperties); | ||||||||||||
3134 | } | ||||||||||||
3135 | |||||||||||||
3136 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3137 | { | ||||||||||||
3138 | --nLevel; | ||||||||||||
3139 | } | ||||||||||||
3140 | |||||||||||||
3141 | if (!nLevel) | ||||||||||||
3142 | break; | ||||||||||||
3143 | } | ||||||||||||
3144 | |||||||||||||
3145 | return aProperties; | ||||||||||||
3146 | } | ||||||||||||
3147 | |||||||||||||
3148 | void VclBuilder::applyAtkProperties(vcl::Window *pWindow, const stringmap& rProperties) | ||||||||||||
3149 | { | ||||||||||||
3150 | assert(pWindow)(static_cast <bool> (pWindow) ? void (0) : __assert_fail ("pWindow", "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 3150, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
3151 | for (auto const& prop : rProperties) | ||||||||||||
3152 | { | ||||||||||||
3153 | const OString &rKey = prop.first; | ||||||||||||
3154 | const OUString &rValue = prop.second; | ||||||||||||
3155 | |||||||||||||
3156 | if (pWindow && rKey.match("AtkObject::")) | ||||||||||||
3157 | pWindow->set_property(rKey.copy(RTL_CONSTASCII_LENGTH("AtkObject::")((sal_Int32)((sizeof(sal_n_array_size("AtkObject::")))-1))), rValue); | ||||||||||||
3158 | else | ||||||||||||
3159 | SAL_WARN("vcl.builder", "unhandled atk prop: " << rKey)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled atk prop: " << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3159" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled atk prop: " << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled atk prop: " << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3159" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled atk prop: " << rKey) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3159" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled atk prop: " << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled atk prop: " << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3159" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
3160 | } | ||||||||||||
3161 | } | ||||||||||||
3162 | |||||||||||||
3163 | std::vector<ComboBoxTextItem> VclBuilder::handleItems(xmlreader::XmlReader &reader) const | ||||||||||||
3164 | { | ||||||||||||
3165 | int nLevel = 1; | ||||||||||||
3166 | |||||||||||||
3167 | std::vector<ComboBoxTextItem> aItems; | ||||||||||||
3168 | |||||||||||||
3169 | while(true) | ||||||||||||
3170 | { | ||||||||||||
3171 | xmlreader::Span name; | ||||||||||||
3172 | int nsId; | ||||||||||||
3173 | |||||||||||||
3174 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3175 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3176 | |||||||||||||
3177 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3178 | break; | ||||||||||||
3179 | |||||||||||||
3180 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3181 | { | ||||||||||||
3182 | ++nLevel; | ||||||||||||
3183 | if (name == "item") | ||||||||||||
3184 | { | ||||||||||||
3185 | bool bTranslated = false; | ||||||||||||
3186 | OString sContext, sId; | ||||||||||||
3187 | |||||||||||||
3188 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
3189 | { | ||||||||||||
3190 | if (name == "translatable" && reader.getAttributeValue(false) == "yes") | ||||||||||||
3191 | { | ||||||||||||
3192 | bTranslated = true; | ||||||||||||
3193 | } | ||||||||||||
3194 | else if (name == "context") | ||||||||||||
3195 | { | ||||||||||||
3196 | name = reader.getAttributeValue(false); | ||||||||||||
3197 | sContext = OString(name.begin, name.length); | ||||||||||||
3198 | } | ||||||||||||
3199 | else if (name == "id") | ||||||||||||
3200 | { | ||||||||||||
3201 | name = reader.getAttributeValue(false); | ||||||||||||
3202 | sId = OString(name.begin, name.length); | ||||||||||||
3203 | } | ||||||||||||
3204 | } | ||||||||||||
3205 | |||||||||||||
3206 | (void)reader.nextItem( | ||||||||||||
3207 | xmlreader::XmlReader::Text::Raw, &name, &nsId); | ||||||||||||
3208 | |||||||||||||
3209 | OString sValue(name.begin, name.length); | ||||||||||||
3210 | OUString sFinalValue; | ||||||||||||
3211 | if (bTranslated) | ||||||||||||
3212 | { | ||||||||||||
3213 | if (!sContext.isEmpty()) | ||||||||||||
3214 | sValue = sContext + "\004" + sValue; | ||||||||||||
3215 | sFinalValue = Translate::get(sValue.getStr(), m_pParserState->m_aResLocale); | ||||||||||||
3216 | } | ||||||||||||
3217 | else | ||||||||||||
3218 | sFinalValue = OUString::fromUtf8(sValue); | ||||||||||||
3219 | |||||||||||||
3220 | if (m_pStringReplace) | ||||||||||||
3221 | sFinalValue = (*m_pStringReplace)(sFinalValue); | ||||||||||||
3222 | |||||||||||||
3223 | aItems.emplace_back(sFinalValue, sId); | ||||||||||||
3224 | } | ||||||||||||
3225 | } | ||||||||||||
3226 | |||||||||||||
3227 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3228 | { | ||||||||||||
3229 | --nLevel; | ||||||||||||
3230 | } | ||||||||||||
3231 | |||||||||||||
3232 | if (!nLevel) | ||||||||||||
3233 | break; | ||||||||||||
3234 | } | ||||||||||||
3235 | |||||||||||||
3236 | return aItems; | ||||||||||||
3237 | } | ||||||||||||
3238 | |||||||||||||
3239 | VclPtr<Menu> VclBuilder::handleMenu(xmlreader::XmlReader &reader, const OString &rID, bool bMenuBar) | ||||||||||||
3240 | { | ||||||||||||
3241 | VclPtr<Menu> pCurrentMenu; | ||||||||||||
3242 | if (bMenuBar) | ||||||||||||
3243 | pCurrentMenu = VclPtr<MenuBar>::Create(); | ||||||||||||
3244 | else | ||||||||||||
3245 | pCurrentMenu = VclPtr<PopupMenu>::Create(); | ||||||||||||
3246 | |||||||||||||
3247 | int nLevel = 1; | ||||||||||||
3248 | |||||||||||||
3249 | stringmap aProperties; | ||||||||||||
3250 | |||||||||||||
3251 | while(true) | ||||||||||||
3252 | { | ||||||||||||
3253 | xmlreader::Span name; | ||||||||||||
3254 | int nsId; | ||||||||||||
3255 | |||||||||||||
3256 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3257 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3258 | |||||||||||||
3259 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3260 | break; | ||||||||||||
3261 | |||||||||||||
3262 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3263 | { | ||||||||||||
3264 | if (name == "child") | ||||||||||||
3265 | { | ||||||||||||
3266 | handleMenuChild(pCurrentMenu, reader); | ||||||||||||
3267 | } | ||||||||||||
3268 | else | ||||||||||||
3269 | { | ||||||||||||
3270 | ++nLevel; | ||||||||||||
3271 | if (name == "property") | ||||||||||||
3272 | collectProperty(reader, aProperties); | ||||||||||||
3273 | } | ||||||||||||
3274 | } | ||||||||||||
3275 | |||||||||||||
3276 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3277 | { | ||||||||||||
3278 | --nLevel; | ||||||||||||
3279 | } | ||||||||||||
3280 | |||||||||||||
3281 | if (!nLevel) | ||||||||||||
3282 | break; | ||||||||||||
3283 | } | ||||||||||||
3284 | |||||||||||||
3285 | m_aMenus.emplace_back(rID, pCurrentMenu); | ||||||||||||
3286 | |||||||||||||
3287 | return pCurrentMenu; | ||||||||||||
3288 | } | ||||||||||||
3289 | |||||||||||||
3290 | void VclBuilder::handleMenuChild(Menu *pParent, xmlreader::XmlReader &reader) | ||||||||||||
3291 | { | ||||||||||||
3292 | xmlreader::Span name; | ||||||||||||
3293 | int nsId; | ||||||||||||
3294 | |||||||||||||
3295 | int nLevel = 1; | ||||||||||||
3296 | while(true) | ||||||||||||
3297 | { | ||||||||||||
3298 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3299 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3300 | |||||||||||||
3301 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3302 | { | ||||||||||||
3303 | if (name == "object" || name == "placeholder") | ||||||||||||
3304 | { | ||||||||||||
3305 | handleMenuObject(pParent, reader); | ||||||||||||
3306 | } | ||||||||||||
3307 | else | ||||||||||||
3308 | ++nLevel; | ||||||||||||
3309 | } | ||||||||||||
3310 | |||||||||||||
3311 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3312 | --nLevel; | ||||||||||||
3313 | |||||||||||||
3314 | if (!nLevel) | ||||||||||||
3315 | break; | ||||||||||||
3316 | |||||||||||||
3317 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3318 | break; | ||||||||||||
3319 | } | ||||||||||||
3320 | } | ||||||||||||
3321 | |||||||||||||
3322 | void VclBuilder::handleMenuObject(Menu *pParent, xmlreader::XmlReader &reader) | ||||||||||||
3323 | { | ||||||||||||
3324 | OString sClass; | ||||||||||||
3325 | OString sID; | ||||||||||||
3326 | OUString sCustomProperty; | ||||||||||||
3327 | PopupMenu *pSubMenu = nullptr; | ||||||||||||
3328 | |||||||||||||
3329 | xmlreader::Span name; | ||||||||||||
3330 | int nsId; | ||||||||||||
3331 | |||||||||||||
3332 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
3333 | { | ||||||||||||
3334 | if (name == "class") | ||||||||||||
3335 | { | ||||||||||||
3336 | name = reader.getAttributeValue(false); | ||||||||||||
3337 | sClass = OString(name.begin, name.length); | ||||||||||||
3338 | } | ||||||||||||
3339 | else if (name == "id") | ||||||||||||
3340 | { | ||||||||||||
3341 | name = reader.getAttributeValue(false); | ||||||||||||
3342 | sID = OString(name.begin, name.length); | ||||||||||||
3343 | sal_Int32 nDelim = sID.indexOf(':'); | ||||||||||||
3344 | if (nDelim != -1) | ||||||||||||
3345 | { | ||||||||||||
3346 | sCustomProperty = OUString::fromUtf8(sID.copy(nDelim+1)); | ||||||||||||
3347 | sID = sID.copy(0, nDelim); | ||||||||||||
3348 | } | ||||||||||||
3349 | } | ||||||||||||
3350 | } | ||||||||||||
3351 | |||||||||||||
3352 | int nLevel = 1; | ||||||||||||
3353 | |||||||||||||
3354 | stringmap aProperties; | ||||||||||||
3355 | stringmap aAtkProperties; | ||||||||||||
3356 | accelmap aAccelerators; | ||||||||||||
3357 | |||||||||||||
3358 | if (!sCustomProperty.isEmpty()) | ||||||||||||
3359 | aProperties[OString("customproperty")] = sCustomProperty; | ||||||||||||
3360 | |||||||||||||
3361 | while(true) | ||||||||||||
3362 | { | ||||||||||||
3363 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3364 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3365 | |||||||||||||
3366 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3367 | break; | ||||||||||||
3368 | |||||||||||||
3369 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3370 | { | ||||||||||||
3371 | if (name == "child") | ||||||||||||
3372 | { | ||||||||||||
3373 | size_t nChildMenuIdx = m_aMenus.size(); | ||||||||||||
3374 | handleChild(nullptr, &aAtkProperties, reader); | ||||||||||||
3375 | bool bSubMenuInserted = m_aMenus.size() > nChildMenuIdx; | ||||||||||||
3376 | if (bSubMenuInserted) | ||||||||||||
3377 | pSubMenu = dynamic_cast<PopupMenu*>(m_aMenus[nChildMenuIdx].m_pMenu.get()); | ||||||||||||
3378 | } | ||||||||||||
3379 | else | ||||||||||||
3380 | { | ||||||||||||
3381 | ++nLevel; | ||||||||||||
3382 | if (name == "property") | ||||||||||||
3383 | collectProperty(reader, aProperties); | ||||||||||||
3384 | else if (name == "accelerator") | ||||||||||||
3385 | collectAccelerator(reader, aAccelerators); | ||||||||||||
3386 | } | ||||||||||||
3387 | } | ||||||||||||
3388 | |||||||||||||
3389 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3390 | { | ||||||||||||
3391 | --nLevel; | ||||||||||||
3392 | } | ||||||||||||
3393 | |||||||||||||
3394 | if (!nLevel) | ||||||||||||
3395 | break; | ||||||||||||
3396 | } | ||||||||||||
3397 | |||||||||||||
3398 | insertMenuObject(pParent, pSubMenu, sClass, sID, aProperties, aAtkProperties, aAccelerators); | ||||||||||||
3399 | } | ||||||||||||
3400 | |||||||||||||
3401 | void VclBuilder::handleSizeGroup(xmlreader::XmlReader &reader) | ||||||||||||
3402 | { | ||||||||||||
3403 | m_pParserState->m_aSizeGroups.emplace_back(); | ||||||||||||
3404 | SizeGroup &rSizeGroup = m_pParserState->m_aSizeGroups.back(); | ||||||||||||
3405 | |||||||||||||
3406 | int nLevel = 1; | ||||||||||||
3407 | |||||||||||||
3408 | while(true) | ||||||||||||
3409 | { | ||||||||||||
3410 | xmlreader::Span name; | ||||||||||||
3411 | int nsId; | ||||||||||||
3412 | |||||||||||||
3413 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3414 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3415 | |||||||||||||
3416 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3417 | break; | ||||||||||||
3418 | |||||||||||||
3419 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3420 | { | ||||||||||||
3421 | ++nLevel; | ||||||||||||
3422 | if (name == "widget") | ||||||||||||
3423 | { | ||||||||||||
3424 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
3425 | { | ||||||||||||
3426 | if (name == "name") | ||||||||||||
3427 | { | ||||||||||||
3428 | name = reader.getAttributeValue(false); | ||||||||||||
3429 | OString sWidget(name.begin, name.length); | ||||||||||||
3430 | sal_Int32 nDelim = sWidget.indexOf(':'); | ||||||||||||
3431 | if (nDelim != -1) | ||||||||||||
3432 | sWidget = sWidget.copy(0, nDelim); | ||||||||||||
3433 | rSizeGroup.m_aWidgets.push_back(sWidget); | ||||||||||||
3434 | } | ||||||||||||
3435 | } | ||||||||||||
3436 | } | ||||||||||||
3437 | else | ||||||||||||
3438 | { | ||||||||||||
3439 | if (name == "property") | ||||||||||||
3440 | collectProperty(reader, rSizeGroup.m_aProperties); | ||||||||||||
3441 | } | ||||||||||||
3442 | } | ||||||||||||
3443 | |||||||||||||
3444 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3445 | { | ||||||||||||
3446 | --nLevel; | ||||||||||||
3447 | } | ||||||||||||
3448 | |||||||||||||
3449 | if (!nLevel) | ||||||||||||
3450 | break; | ||||||||||||
3451 | } | ||||||||||||
3452 | } | ||||||||||||
3453 | |||||||||||||
3454 | namespace | ||||||||||||
3455 | { | ||||||||||||
3456 | vcl::KeyCode makeKeyCode(const std::pair<OString,OString> &rKey) | ||||||||||||
3457 | { | ||||||||||||
3458 | bool bShift = rKey.second.indexOf("GDK_SHIFT_MASK") != -1; | ||||||||||||
3459 | bool bMod1 = rKey.second.indexOf("GDK_CONTROL_MASK") != -1; | ||||||||||||
3460 | bool bMod2 = rKey.second.indexOf("GDK_MOD1_MASK") != -1; | ||||||||||||
3461 | bool bMod3 = rKey.second.indexOf("GDK_MOD2_MASK") != -1; | ||||||||||||
3462 | |||||||||||||
3463 | if (rKey.first == "Insert") | ||||||||||||
3464 | return vcl::KeyCode(KEY_INSERT, bShift, bMod1, bMod2, bMod3); | ||||||||||||
3465 | else if (rKey.first == "Delete") | ||||||||||||
3466 | return vcl::KeyCode(KEY_DELETE, bShift, bMod1, bMod2, bMod3); | ||||||||||||
3467 | else if (rKey.first == "Return") | ||||||||||||
3468 | return vcl::KeyCode(KEY_RETURN, bShift, bMod1, bMod2, bMod3); | ||||||||||||
3469 | else if (rKey.first == "Up") | ||||||||||||
3470 | return vcl::KeyCode(KEY_UP, bShift, bMod1, bMod2, bMod3); | ||||||||||||
3471 | else if (rKey.first == "Down") | ||||||||||||
3472 | return vcl::KeyCode(KEY_DOWN, bShift, bMod1, bMod2, bMod3); | ||||||||||||
3473 | else if (rKey.first == "Left") | ||||||||||||
3474 | return vcl::KeyCode(KEY_LEFT, bShift, bMod1, bMod2, bMod3); | ||||||||||||
3475 | else if (rKey.first == "Right") | ||||||||||||
3476 | return vcl::KeyCode(KEY_RIGHT, bShift, bMod1, bMod2, bMod3); | ||||||||||||
3477 | else if (rKey.first == "asterisk") | ||||||||||||
3478 | return vcl::KeyCode(KEY_MULTIPLY, bShift, bMod1, bMod2, bMod3); | ||||||||||||
3479 | |||||||||||||
3480 | assert (rKey.first.getLength() == 1)(static_cast <bool> (rKey.first.getLength() == 1) ? void (0) : __assert_fail ("rKey.first.getLength() == 1", "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 3480, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
3481 | char cChar = rKey.first.toChar(); | ||||||||||||
3482 | |||||||||||||
3483 | if (cChar >= 'a' && cChar <= 'z') | ||||||||||||
3484 | return vcl::KeyCode(KEY_A + (cChar - 'a'), bShift, bMod1, bMod2, bMod3); | ||||||||||||
3485 | else if (cChar >= 'A' && cChar <= 'Z') | ||||||||||||
3486 | return vcl::KeyCode(KEY_A + (cChar - 'A'), bShift, bMod1, bMod2, bMod3); | ||||||||||||
3487 | else if (cChar >= '0' && cChar <= '9') | ||||||||||||
3488 | return vcl::KeyCode(KEY_0 + (cChar - 'A'), bShift, bMod1, bMod2, bMod3); | ||||||||||||
3489 | |||||||||||||
3490 | return vcl::KeyCode(cChar, bShift, bMod1, bMod2, bMod3); | ||||||||||||
3491 | } | ||||||||||||
3492 | } | ||||||||||||
3493 | |||||||||||||
3494 | void VclBuilder::insertMenuObject(Menu *pParent, PopupMenu *pSubMenu, const OString &rClass, const OString &rID, | ||||||||||||
3495 | stringmap &rProps, stringmap &rAtkProps, accelmap &rAccels) | ||||||||||||
3496 | { | ||||||||||||
3497 | sal_uInt16 nOldCount = pParent->GetItemCount(); | ||||||||||||
3498 | sal_uInt16 nNewId = ++m_pParserState->m_nLastMenuItemId; | ||||||||||||
3499 | |||||||||||||
3500 | if(rClass == "NotebookBarAddonsMenuMergePoint") | ||||||||||||
3501 | { | ||||||||||||
3502 | NotebookBarAddonsMerger::MergeNotebookBarMenuAddons(pParent, nNewId, rID, *m_pNotebookBarAddonsItem); | ||||||||||||
3503 | m_pParserState->m_nLastMenuItemId = pParent->GetItemCount(); | ||||||||||||
3504 | } | ||||||||||||
3505 | else if (rClass == "GtkMenuItem") | ||||||||||||
3506 | { | ||||||||||||
3507 | OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps))); | ||||||||||||
3508 | OUString aCommand(extractActionName(rProps)); | ||||||||||||
3509 | pParent->InsertItem(nNewId, sLabel, MenuItemBits::NONE , rID); | ||||||||||||
3510 | pParent->SetItemCommand(nNewId, aCommand); | ||||||||||||
3511 | if (pSubMenu) | ||||||||||||
3512 | pParent->SetPopupMenu(nNewId, pSubMenu); | ||||||||||||
3513 | } | ||||||||||||
3514 | else if (rClass == "GtkCheckMenuItem") | ||||||||||||
3515 | { | ||||||||||||
3516 | OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps))); | ||||||||||||
3517 | OUString aCommand(extractActionName(rProps)); | ||||||||||||
3518 | pParent->InsertItem(nNewId, sLabel, MenuItemBits::CHECKABLE, rID); | ||||||||||||
3519 | pParent->SetItemCommand(nNewId, aCommand); | ||||||||||||
3520 | } | ||||||||||||
3521 | else if (rClass == "GtkRadioMenuItem") | ||||||||||||
3522 | { | ||||||||||||
3523 | OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps))); | ||||||||||||
3524 | OUString aCommand(extractActionName(rProps)); | ||||||||||||
3525 | pParent->InsertItem(nNewId, sLabel, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK, rID); | ||||||||||||
3526 | pParent->SetItemCommand(nNewId, aCommand); | ||||||||||||
3527 | } | ||||||||||||
3528 | else if (rClass == "GtkSeparatorMenuItem") | ||||||||||||
3529 | { | ||||||||||||
3530 | pParent->InsertSeparator(rID); | ||||||||||||
3531 | } | ||||||||||||
3532 | |||||||||||||
3533 | SAL_WARN_IF(nOldCount == pParent->GetItemCount(), "vcl.builder", "probably need to implement " << rClass)do { if (true && (nOldCount == pParent->GetItemCount ())) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "probably need to implement " << rClass) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3533" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "probably need to implement " << rClass), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "probably need to implement " << rClass; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3533" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "probably need to implement " << rClass) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3533" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "probably need to implement " << rClass), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "probably need to implement " << rClass; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3533" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
3534 | |||||||||||||
3535 | if (nOldCount != pParent->GetItemCount()) | ||||||||||||
3536 | { | ||||||||||||
3537 | pParent->SetHelpId(nNewId, m_sHelpRoot + rID); | ||||||||||||
3538 | if (!extractVisible(rProps)) | ||||||||||||
3539 | pParent->HideItem(nNewId); | ||||||||||||
3540 | |||||||||||||
3541 | for (auto const& prop : rProps) | ||||||||||||
3542 | { | ||||||||||||
3543 | const OString &rKey = prop.first; | ||||||||||||
3544 | const OUString &rValue = prop.second; | ||||||||||||
3545 | |||||||||||||
3546 | if (rKey == "tooltip-markup") | ||||||||||||
3547 | pParent->SetTipHelpText(nNewId, rValue); | ||||||||||||
3548 | else if (rKey == "tooltip-text") | ||||||||||||
3549 | pParent->SetTipHelpText(nNewId, rValue); | ||||||||||||
3550 | else | ||||||||||||
3551 | SAL_INFO("vcl.builder", "unhandled property: " << rKey)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled property: " << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3551" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property: " << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property: " << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3551" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled property: " << rKey) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3551" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property: " << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property: " << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3551" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
3552 | } | ||||||||||||
3553 | |||||||||||||
3554 | for (auto const& prop : rAtkProps) | ||||||||||||
3555 | { | ||||||||||||
3556 | const OString &rKey = prop.first; | ||||||||||||
3557 | const OUString &rValue = prop.second; | ||||||||||||
3558 | |||||||||||||
3559 | if (rKey == "AtkObject::accessible-name") | ||||||||||||
3560 | pParent->SetAccessibleName(nNewId, rValue); | ||||||||||||
3561 | else if (rKey == "AtkObject::accessible-description") | ||||||||||||
3562 | pParent->SetAccessibleDescription(nNewId, rValue); | ||||||||||||
3563 | else | ||||||||||||
3564 | SAL_INFO("vcl.builder", "unhandled atk property: " << rKey)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled atk property: " << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3564" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled atk property: " << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled atk property: " << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3564" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled atk property: " << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3564" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled atk property: " << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled atk property: " << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3564" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
3565 | } | ||||||||||||
3566 | |||||||||||||
3567 | for (auto const& accel : rAccels) | ||||||||||||
3568 | { | ||||||||||||
3569 | const OString &rSignal = accel.first; | ||||||||||||
3570 | const auto &rValue = accel.second; | ||||||||||||
3571 | |||||||||||||
3572 | if (rSignal == "activate") | ||||||||||||
3573 | pParent->SetAccelKey(nNewId, makeKeyCode(rValue)); | ||||||||||||
3574 | else | ||||||||||||
3575 | SAL_INFO("vcl.builder", "unhandled accelerator for: " << rSignal)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled accelerator for: " << rSignal) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3575" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled accelerator for: " << rSignal), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "unhandled accelerator for: " << rSignal; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ( "vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3575" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled accelerator for: " << rSignal) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3575" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled accelerator for: " << rSignal), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "unhandled accelerator for: " << rSignal; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ( "vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3575" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
3576 | } | ||||||||||||
3577 | } | ||||||||||||
3578 | |||||||||||||
3579 | rProps.clear(); | ||||||||||||
3580 | } | ||||||||||||
3581 | |||||||||||||
3582 | /// Insert items to a ComboBox or a ListBox. | ||||||||||||
3583 | /// They have no common ancestor that would have 'InsertEntry()', so use a template. | ||||||||||||
3584 | template<typename T> static bool insertItems(vcl::Window *pWindow, VclBuilder::stringmap &rMap, | ||||||||||||
3585 | std::vector<std::unique_ptr<OUString>>& rUserData, | ||||||||||||
3586 | const std::vector<ComboBoxTextItem> &rItems) | ||||||||||||
3587 | { | ||||||||||||
3588 | T *pContainer = dynamic_cast<T*>(pWindow); | ||||||||||||
3589 | if (!pContainer) | ||||||||||||
3590 | return false; | ||||||||||||
3591 | |||||||||||||
3592 | sal_uInt16 nActiveId = extractActive(rMap); | ||||||||||||
3593 | for (auto const& item : rItems) | ||||||||||||
3594 | { | ||||||||||||
3595 | sal_Int32 nPos = pContainer->InsertEntry(item.m_sItem); | ||||||||||||
3596 | if (!item.m_sId.isEmpty()) | ||||||||||||
3597 | { | ||||||||||||
3598 | rUserData.emplace_back(std::make_unique<OUString>(OUString::fromUtf8(item.m_sId))); | ||||||||||||
3599 | pContainer->SetEntryData(nPos, rUserData.back().get()); | ||||||||||||
3600 | } | ||||||||||||
3601 | } | ||||||||||||
3602 | if (nActiveId < rItems.size()) | ||||||||||||
3603 | pContainer->SelectEntryPos(nActiveId); | ||||||||||||
3604 | |||||||||||||
3605 | return true; | ||||||||||||
3606 | } | ||||||||||||
3607 | |||||||||||||
3608 | VclPtr<vcl::Window> VclBuilder::handleObject(vcl::Window *pParent, stringmap *pAtkProps, xmlreader::XmlReader &reader) | ||||||||||||
3609 | { | ||||||||||||
3610 | OString sClass; | ||||||||||||
3611 | OString sID; | ||||||||||||
3612 | OUString sCustomProperty; | ||||||||||||
3613 | |||||||||||||
3614 | xmlreader::Span name; | ||||||||||||
3615 | int nsId; | ||||||||||||
3616 | |||||||||||||
3617 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
3618 | { | ||||||||||||
3619 | if (name == "class") | ||||||||||||
3620 | { | ||||||||||||
3621 | name = reader.getAttributeValue(false); | ||||||||||||
3622 | sClass = OString(name.begin, name.length); | ||||||||||||
3623 | } | ||||||||||||
3624 | else if (name == "id") | ||||||||||||
3625 | { | ||||||||||||
3626 | name = reader.getAttributeValue(false); | ||||||||||||
3627 | sID = OString(name.begin, name.length); | ||||||||||||
3628 | if (m_bLegacy) | ||||||||||||
3629 | { | ||||||||||||
3630 | sal_Int32 nDelim = sID.indexOf(':'); | ||||||||||||
3631 | if (nDelim != -1) | ||||||||||||
3632 | { | ||||||||||||
3633 | sCustomProperty = OUString::fromUtf8(sID.copy(nDelim+1)); | ||||||||||||
3634 | sID = sID.copy(0, nDelim); | ||||||||||||
3635 | } | ||||||||||||
3636 | } | ||||||||||||
3637 | } | ||||||||||||
3638 | } | ||||||||||||
3639 | |||||||||||||
3640 | if (sClass == "GtkListStore" || sClass == "GtkTreeStore") | ||||||||||||
3641 | { | ||||||||||||
3642 | handleListStore(reader, sID, sClass); | ||||||||||||
3643 | return nullptr; | ||||||||||||
3644 | } | ||||||||||||
3645 | else if (sClass == "GtkMenu") | ||||||||||||
3646 | { | ||||||||||||
3647 | handleMenu(reader, sID, false); | ||||||||||||
3648 | return nullptr; | ||||||||||||
3649 | } | ||||||||||||
3650 | else if (sClass == "GtkMenuBar") | ||||||||||||
3651 | { | ||||||||||||
3652 | VclPtr<Menu> xMenu = handleMenu(reader, sID, true); | ||||||||||||
3653 | if (SystemWindow* pTopLevel = pParent ? pParent->GetSystemWindow() : nullptr) | ||||||||||||
3654 | pTopLevel->SetMenuBar(dynamic_cast<MenuBar*>(xMenu.get())); | ||||||||||||
3655 | return nullptr; | ||||||||||||
3656 | } | ||||||||||||
3657 | else if (sClass == "GtkSizeGroup") | ||||||||||||
3658 | { | ||||||||||||
3659 | handleSizeGroup(reader); | ||||||||||||
3660 | return nullptr; | ||||||||||||
3661 | } | ||||||||||||
3662 | else if (sClass == "AtkObject") | ||||||||||||
3663 | { | ||||||||||||
3664 | assert((pParent || pAtkProps) && "must have one set")(static_cast <bool> ((pParent || pAtkProps) && "must have one set" ) ? void (0) : __assert_fail ("(pParent || pAtkProps) && \"must have one set\"" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 3664, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
3665 | assert(!(pParent && pAtkProps) && "must not have both")(static_cast <bool> (!(pParent && pAtkProps) && "must not have both") ? void (0) : __assert_fail ("!(pParent && pAtkProps) && \"must not have both\"" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 3665, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
3666 | auto aAtkProperties = handleAtkObject(reader); | ||||||||||||
3667 | if (pParent) | ||||||||||||
3668 | applyAtkProperties(pParent, aAtkProperties); | ||||||||||||
3669 | if (pAtkProps) | ||||||||||||
3670 | *pAtkProps = aAtkProperties; | ||||||||||||
3671 | return nullptr; | ||||||||||||
3672 | } | ||||||||||||
3673 | |||||||||||||
3674 | int nLevel = 1; | ||||||||||||
3675 | |||||||||||||
3676 | stringmap aProperties, aPangoAttributes; | ||||||||||||
3677 | stringmap aAtkAttributes; | ||||||||||||
3678 | std::vector<ComboBoxTextItem> aItems; | ||||||||||||
3679 | |||||||||||||
3680 | if (!sCustomProperty.isEmpty()) | ||||||||||||
3681 | aProperties[OString("customproperty")] = sCustomProperty; | ||||||||||||
3682 | |||||||||||||
3683 | VclPtr<vcl::Window> pCurrentChild; | ||||||||||||
3684 | while(true) | ||||||||||||
3685 | { | ||||||||||||
3686 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3687 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3688 | |||||||||||||
3689 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3690 | break; | ||||||||||||
3691 | |||||||||||||
3692 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3693 | { | ||||||||||||
3694 | if (name == "child") | ||||||||||||
3695 | { | ||||||||||||
3696 | if (!pCurrentChild) | ||||||||||||
3697 | { | ||||||||||||
3698 | pCurrentChild = insertObject(pParent, sClass, sID, | ||||||||||||
3699 | aProperties, aPangoAttributes, aAtkAttributes); | ||||||||||||
3700 | } | ||||||||||||
3701 | handleChild(pCurrentChild, nullptr, reader); | ||||||||||||
3702 | } | ||||||||||||
3703 | else if (name == "items") | ||||||||||||
3704 | aItems = handleItems(reader); | ||||||||||||
3705 | else if (name == "style") | ||||||||||||
3706 | { | ||||||||||||
3707 | int nPriority = 0; | ||||||||||||
3708 | std::vector<vcl::EnumContext::Context> aContext = handleStyle(reader, nPriority); | ||||||||||||
3709 | if (nPriority != 0) | ||||||||||||
3710 | { | ||||||||||||
3711 | vcl::IPrioritable* pPrioritable = dynamic_cast<vcl::IPrioritable*>(pCurrentChild.get()); | ||||||||||||
3712 | SAL_WARN_IF(!pPrioritable, "vcl", "priority set for not supported item")do { if (true && (!pPrioritable)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "priority set for not supported item" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3712" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "priority set for not supported item" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "priority set for not supported item"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3712" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "priority set for not supported item") == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3712" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "priority set for not supported item" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "priority set for not supported item"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3712" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
3713 | if (pPrioritable) | ||||||||||||
3714 | pPrioritable->SetPriority(nPriority); | ||||||||||||
3715 | } | ||||||||||||
3716 | if (!aContext.empty()) | ||||||||||||
3717 | { | ||||||||||||
3718 | vcl::IContext* pContextControl = dynamic_cast<vcl::IContext*>(pCurrentChild.get()); | ||||||||||||
3719 | SAL_WARN_IF(!pContextControl, "vcl", "context set for not supported item")do { if (true && (!pContextControl)) { switch (sal_detail_log_report (::SAL_DETAIL_LOG_LEVEL_WARN, "vcl")) { case SAL_DETAIL_LOG_ACTION_IGNORE : break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail ::getResult( ::sal::detail::StreamStart() << "context set for not supported item" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3719" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "context set for not supported item" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "context set for not supported item"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3719" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "context set for not supported item") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3719" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "context set for not supported item" ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "context set for not supported item"; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3719" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
3720 | if (pContextControl) | ||||||||||||
3721 | pContextControl->SetContext(aContext); | ||||||||||||
3722 | } | ||||||||||||
3723 | } | ||||||||||||
3724 | else | ||||||||||||
3725 | { | ||||||||||||
3726 | ++nLevel; | ||||||||||||
3727 | if (name == "property") | ||||||||||||
3728 | collectProperty(reader, aProperties); | ||||||||||||
3729 | else if (name == "attribute") | ||||||||||||
3730 | collectPangoAttribute(reader, aPangoAttributes); | ||||||||||||
3731 | else if (name == "relation") | ||||||||||||
3732 | collectAtkRelationAttribute(reader, aAtkAttributes); | ||||||||||||
3733 | else if (name == "role") | ||||||||||||
3734 | collectAtkRoleAttribute(reader, aAtkAttributes); | ||||||||||||
3735 | else if (name == "action-widget") | ||||||||||||
3736 | handleActionWidget(reader); | ||||||||||||
3737 | } | ||||||||||||
3738 | } | ||||||||||||
3739 | |||||||||||||
3740 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3741 | { | ||||||||||||
3742 | --nLevel; | ||||||||||||
3743 | } | ||||||||||||
3744 | |||||||||||||
3745 | if (!nLevel) | ||||||||||||
3746 | break; | ||||||||||||
3747 | } | ||||||||||||
3748 | |||||||||||||
3749 | if (sClass == "GtkAdjustment") | ||||||||||||
3750 | { | ||||||||||||
3751 | m_pParserState->m_aAdjustments[sID] = aProperties; | ||||||||||||
3752 | return nullptr; | ||||||||||||
3753 | } | ||||||||||||
3754 | else if (sClass == "GtkTextBuffer") | ||||||||||||
3755 | { | ||||||||||||
3756 | m_pParserState->m_aTextBuffers[sID] = aProperties; | ||||||||||||
3757 | return nullptr; | ||||||||||||
3758 | } | ||||||||||||
3759 | |||||||||||||
3760 | if (!pCurrentChild) | ||||||||||||
3761 | { | ||||||||||||
3762 | pCurrentChild = insertObject(pParent, sClass, sID, aProperties, | ||||||||||||
3763 | aPangoAttributes, aAtkAttributes); | ||||||||||||
3764 | } | ||||||||||||
3765 | |||||||||||||
3766 | if (!aItems.empty()) | ||||||||||||
3767 | { | ||||||||||||
3768 | // try to fill-in the items | ||||||||||||
3769 | if (!insertItems<ComboBox>(pCurrentChild, aProperties, m_aUserData, aItems)) | ||||||||||||
3770 | insertItems<ListBox>(pCurrentChild, aProperties, m_aUserData, aItems); | ||||||||||||
3771 | } | ||||||||||||
3772 | |||||||||||||
3773 | return pCurrentChild; | ||||||||||||
3774 | } | ||||||||||||
3775 | |||||||||||||
3776 | void VclBuilder::handlePacking(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader) | ||||||||||||
3777 | { | ||||||||||||
3778 | xmlreader::Span name; | ||||||||||||
3779 | int nsId; | ||||||||||||
3780 | |||||||||||||
3781 | int nLevel = 1; | ||||||||||||
3782 | |||||||||||||
3783 | while(true) | ||||||||||||
3784 | { | ||||||||||||
3785 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3786 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3787 | |||||||||||||
3788 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3789 | break; | ||||||||||||
3790 | |||||||||||||
3791 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3792 | { | ||||||||||||
3793 | ++nLevel; | ||||||||||||
3794 | if (name == "property") | ||||||||||||
3795 | applyPackingProperty(pCurrent, pParent, reader); | ||||||||||||
3796 | } | ||||||||||||
3797 | |||||||||||||
3798 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3799 | { | ||||||||||||
3800 | --nLevel; | ||||||||||||
3801 | } | ||||||||||||
3802 | |||||||||||||
3803 | if (!nLevel) | ||||||||||||
3804 | break; | ||||||||||||
3805 | } | ||||||||||||
3806 | } | ||||||||||||
3807 | |||||||||||||
3808 | void VclBuilder::applyPackingProperty(vcl::Window *pCurrent, | ||||||||||||
3809 | vcl::Window *pParent, | ||||||||||||
3810 | xmlreader::XmlReader &reader) | ||||||||||||
3811 | { | ||||||||||||
3812 | if (!pCurrent) | ||||||||||||
3813 | return; | ||||||||||||
3814 | |||||||||||||
3815 | //ToolBoxItems are not true widgets just elements | ||||||||||||
3816 | //of the ToolBox itself | ||||||||||||
3817 | ToolBox *pToolBoxParent = nullptr; | ||||||||||||
3818 | if (pCurrent == pParent) | ||||||||||||
3819 | pToolBoxParent = dynamic_cast<ToolBox*>(pParent); | ||||||||||||
3820 | |||||||||||||
3821 | xmlreader::Span name; | ||||||||||||
3822 | int nsId; | ||||||||||||
3823 | |||||||||||||
3824 | if (pCurrent->GetType() == WindowType::SCROLLWINDOW) | ||||||||||||
3825 | { | ||||||||||||
3826 | auto aFind = m_pParserState->m_aRedundantParentWidgets.find(VclPtr<vcl::Window>(pCurrent)); | ||||||||||||
3827 | if (aFind != m_pParserState->m_aRedundantParentWidgets.end()) | ||||||||||||
3828 | { | ||||||||||||
3829 | pCurrent = aFind->second; | ||||||||||||
3830 | assert(pCurrent)(static_cast <bool> (pCurrent) ? void (0) : __assert_fail ("pCurrent", "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 3830, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
3831 | } | ||||||||||||
3832 | } | ||||||||||||
3833 | |||||||||||||
3834 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
3835 | { | ||||||||||||
3836 | if (name == "name") | ||||||||||||
3837 | { | ||||||||||||
3838 | name = reader.getAttributeValue(false); | ||||||||||||
3839 | OString sKey(name.begin, name.length); | ||||||||||||
3840 | sKey = sKey.replace('_', '-'); | ||||||||||||
3841 | (void)reader.nextItem( | ||||||||||||
3842 | xmlreader::XmlReader::Text::Raw, &name, &nsId); | ||||||||||||
3843 | OString sValue(name.begin, name.length); | ||||||||||||
3844 | |||||||||||||
3845 | if (sKey == "expand" || sKey == "resize") | ||||||||||||
3846 | { | ||||||||||||
3847 | bool bTrue = (!sValue.isEmpty() && (sValue[0] == 't' || sValue[0] == 'T' || sValue[0] == '1')); | ||||||||||||
3848 | if (pToolBoxParent) | ||||||||||||
3849 | pToolBoxParent->SetItemExpand(m_pParserState->m_nLastToolbarId, bTrue); | ||||||||||||
3850 | else | ||||||||||||
3851 | pCurrent->set_expand(bTrue); | ||||||||||||
3852 | continue; | ||||||||||||
3853 | } | ||||||||||||
3854 | |||||||||||||
3855 | if (pToolBoxParent) | ||||||||||||
3856 | continue; | ||||||||||||
3857 | |||||||||||||
3858 | if (sKey == "fill") | ||||||||||||
3859 | { | ||||||||||||
3860 | bool bTrue = (!sValue.isEmpty() && (sValue[0] == 't' || sValue[0] == 'T' || sValue[0] == '1')); | ||||||||||||
3861 | pCurrent->set_fill(bTrue); | ||||||||||||
3862 | } | ||||||||||||
3863 | else if (sKey == "pack-type") | ||||||||||||
3864 | { | ||||||||||||
3865 | VclPackType ePackType = (!sValue.isEmpty() && (sValue[0] == 'e' || sValue[0] == 'E')) ? VclPackType::End : VclPackType::Start; | ||||||||||||
3866 | pCurrent->set_pack_type(ePackType); | ||||||||||||
3867 | } | ||||||||||||
3868 | else if (sKey == "left-attach") | ||||||||||||
3869 | { | ||||||||||||
3870 | pCurrent->set_grid_left_attach(sValue.toInt32()); | ||||||||||||
3871 | } | ||||||||||||
3872 | else if (sKey == "top-attach") | ||||||||||||
3873 | { | ||||||||||||
3874 | pCurrent->set_grid_top_attach(sValue.toInt32()); | ||||||||||||
3875 | } | ||||||||||||
3876 | else if (sKey == "width") | ||||||||||||
3877 | { | ||||||||||||
3878 | pCurrent->set_grid_width(sValue.toInt32()); | ||||||||||||
3879 | } | ||||||||||||
3880 | else if (sKey == "height") | ||||||||||||
3881 | { | ||||||||||||
3882 | pCurrent->set_grid_height(sValue.toInt32()); | ||||||||||||
3883 | } | ||||||||||||
3884 | else if (sKey == "padding") | ||||||||||||
3885 | { | ||||||||||||
3886 | pCurrent->set_padding(sValue.toInt32()); | ||||||||||||
3887 | } | ||||||||||||
3888 | else if (sKey == "position") | ||||||||||||
3889 | { | ||||||||||||
3890 | set_window_packing_position(pCurrent, sValue.toInt32()); | ||||||||||||
3891 | } | ||||||||||||
3892 | else if (sKey == "secondary") | ||||||||||||
3893 | { | ||||||||||||
3894 | pCurrent->set_secondary(toBool(sValue)); | ||||||||||||
3895 | } | ||||||||||||
3896 | else if (sKey == "non-homogeneous") | ||||||||||||
3897 | { | ||||||||||||
3898 | pCurrent->set_non_homogeneous(toBool(sValue)); | ||||||||||||
3899 | } | ||||||||||||
3900 | else if (sKey == "homogeneous") | ||||||||||||
3901 | { | ||||||||||||
3902 | pCurrent->set_non_homogeneous(!toBool(sValue)); | ||||||||||||
3903 | } | ||||||||||||
3904 | else | ||||||||||||
3905 | { | ||||||||||||
3906 | SAL_WARN("vcl.builder", "unknown packing: " << sKey)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unknown packing: " << sKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3906" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unknown packing: " << sKey), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unknown packing: " << sKey; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3906" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unknown packing: " << sKey) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3906" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unknown packing: " << sKey), 0 ); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unknown packing: " << sKey; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3906" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
3907 | } | ||||||||||||
3908 | } | ||||||||||||
3909 | } | ||||||||||||
3910 | } | ||||||||||||
3911 | |||||||||||||
3912 | std::vector<vcl::EnumContext::Context> VclBuilder::handleStyle(xmlreader::XmlReader &reader, int &nPriority) | ||||||||||||
3913 | { | ||||||||||||
3914 | std::vector<vcl::EnumContext::Context> aContext; | ||||||||||||
3915 | |||||||||||||
3916 | xmlreader::Span name; | ||||||||||||
3917 | int nsId; | ||||||||||||
3918 | |||||||||||||
3919 | int nLevel = 1; | ||||||||||||
3920 | |||||||||||||
3921 | while(true) | ||||||||||||
3922 | { | ||||||||||||
3923 | xmlreader::XmlReader::Result res = reader.nextItem( | ||||||||||||
3924 | xmlreader::XmlReader::Text::NONE, &name, &nsId); | ||||||||||||
3925 | |||||||||||||
3926 | if (res == xmlreader::XmlReader::Result::Done) | ||||||||||||
3927 | break; | ||||||||||||
3928 | |||||||||||||
3929 | if (res == xmlreader::XmlReader::Result::Begin) | ||||||||||||
3930 | { | ||||||||||||
3931 | ++nLevel; | ||||||||||||
3932 | if (name == "class") | ||||||||||||
3933 | { | ||||||||||||
3934 | OString classStyle = getStyleClass(reader); | ||||||||||||
3935 | |||||||||||||
3936 | if (classStyle.startsWith("context-")) | ||||||||||||
3937 | { | ||||||||||||
3938 | OString sContext = classStyle.copy(classStyle.indexOf('-') + 1); | ||||||||||||
3939 | OUString sContext2(sContext.getStr(), sContext.getLength(), RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))); | ||||||||||||
3940 | aContext.push_back(vcl::EnumContext::GetContextEnum(sContext2)); | ||||||||||||
3941 | } | ||||||||||||
3942 | else if (classStyle.startsWith("priority-")) | ||||||||||||
3943 | { | ||||||||||||
3944 | OString aPriority = classStyle.copy(classStyle.indexOf('-') + 1); | ||||||||||||
3945 | OUString aPriority2(aPriority.getStr(), aPriority.getLength(), RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))); | ||||||||||||
3946 | nPriority = aPriority2.toInt32(); | ||||||||||||
3947 | } | ||||||||||||
3948 | else if (classStyle != "small-button") | ||||||||||||
3949 | { | ||||||||||||
3950 | SAL_WARN("vcl.builder", "unknown class: " << classStyle)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unknown class: " << classStyle) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3950" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unknown class: " << classStyle ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unknown class: " << classStyle; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3950" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unknown class: " << classStyle) == 1) { :: sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder" ), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3950" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unknown class: " << classStyle ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unknown class: " << classStyle; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "3950" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
3951 | } | ||||||||||||
3952 | } | ||||||||||||
3953 | } | ||||||||||||
3954 | |||||||||||||
3955 | if (res == xmlreader::XmlReader::Result::End) | ||||||||||||
3956 | { | ||||||||||||
3957 | --nLevel; | ||||||||||||
3958 | } | ||||||||||||
3959 | |||||||||||||
3960 | if (!nLevel) | ||||||||||||
3961 | break; | ||||||||||||
3962 | } | ||||||||||||
3963 | |||||||||||||
3964 | return aContext; | ||||||||||||
3965 | } | ||||||||||||
3966 | |||||||||||||
3967 | OString VclBuilder::getStyleClass(xmlreader::XmlReader &reader) | ||||||||||||
3968 | { | ||||||||||||
3969 | xmlreader::Span name; | ||||||||||||
3970 | int nsId; | ||||||||||||
3971 | OString aRet; | ||||||||||||
3972 | |||||||||||||
3973 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
3974 | { | ||||||||||||
3975 | if (name == "name") | ||||||||||||
3976 | { | ||||||||||||
3977 | name = reader.getAttributeValue(false); | ||||||||||||
3978 | aRet = OString (name.begin, name.length); | ||||||||||||
3979 | } | ||||||||||||
3980 | } | ||||||||||||
3981 | |||||||||||||
3982 | return aRet; | ||||||||||||
3983 | } | ||||||||||||
3984 | |||||||||||||
3985 | void VclBuilder::collectProperty(xmlreader::XmlReader &reader, stringmap &rMap) const | ||||||||||||
3986 | { | ||||||||||||
3987 | xmlreader::Span name; | ||||||||||||
3988 | int nsId; | ||||||||||||
3989 | |||||||||||||
3990 | OString sProperty, sContext; | ||||||||||||
3991 | |||||||||||||
3992 | bool bTranslated = false; | ||||||||||||
3993 | |||||||||||||
3994 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
3995 | { | ||||||||||||
3996 | if (name == "name") | ||||||||||||
3997 | { | ||||||||||||
3998 | name = reader.getAttributeValue(false); | ||||||||||||
3999 | sProperty = OString(name.begin, name.length); | ||||||||||||
4000 | } | ||||||||||||
4001 | else if (name == "context") | ||||||||||||
4002 | { | ||||||||||||
4003 | name = reader.getAttributeValue(false); | ||||||||||||
4004 | sContext = OString(name.begin, name.length); | ||||||||||||
4005 | } | ||||||||||||
4006 | else if (name == "translatable" && reader.getAttributeValue(false) == "yes") | ||||||||||||
4007 | { | ||||||||||||
4008 | bTranslated = true; | ||||||||||||
4009 | } | ||||||||||||
4010 | } | ||||||||||||
4011 | |||||||||||||
4012 | (void)reader.nextItem(xmlreader::XmlReader::Text::Raw, &name, &nsId); | ||||||||||||
4013 | OString sValue(name.begin, name.length); | ||||||||||||
4014 | OUString sFinalValue; | ||||||||||||
4015 | if (bTranslated) | ||||||||||||
4016 | { | ||||||||||||
4017 | if (!sContext.isEmpty()) | ||||||||||||
4018 | sValue = sContext + "\004" + sValue; | ||||||||||||
4019 | sFinalValue = Translate::get(sValue.getStr(), m_pParserState->m_aResLocale); | ||||||||||||
4020 | } | ||||||||||||
4021 | else | ||||||||||||
4022 | sFinalValue = OUString::fromUtf8(sValue); | ||||||||||||
4023 | |||||||||||||
4024 | if (!sProperty.isEmpty()) | ||||||||||||
4025 | { | ||||||||||||
4026 | sProperty = sProperty.replace('_', '-'); | ||||||||||||
4027 | if (m_pStringReplace) | ||||||||||||
4028 | sFinalValue = (*m_pStringReplace)(sFinalValue); | ||||||||||||
4029 | rMap[sProperty] = sFinalValue; | ||||||||||||
4030 | } | ||||||||||||
4031 | } | ||||||||||||
4032 | |||||||||||||
4033 | void VclBuilder::handleActionWidget(xmlreader::XmlReader &reader) | ||||||||||||
4034 | { | ||||||||||||
4035 | xmlreader::Span name; | ||||||||||||
4036 | int nsId; | ||||||||||||
4037 | |||||||||||||
4038 | OString sResponse; | ||||||||||||
4039 | |||||||||||||
4040 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
4041 | { | ||||||||||||
4042 | if (name == "response") | ||||||||||||
4043 | { | ||||||||||||
4044 | name = reader.getAttributeValue(false); | ||||||||||||
4045 | sResponse = OString(name.begin, name.length); | ||||||||||||
4046 | } | ||||||||||||
4047 | } | ||||||||||||
4048 | |||||||||||||
4049 | (void)reader.nextItem(xmlreader::XmlReader::Text::Raw, &name, &nsId); | ||||||||||||
4050 | OString sID(name.begin, name.length); | ||||||||||||
4051 | sal_Int32 nDelim = sID.indexOf(':'); | ||||||||||||
4052 | if (nDelim != -1) | ||||||||||||
4053 | sID = sID.copy(0, nDelim); | ||||||||||||
4054 | set_response(sID, sResponse.toInt32()); | ||||||||||||
4055 | } | ||||||||||||
4056 | |||||||||||||
4057 | void VclBuilder::collectAccelerator(xmlreader::XmlReader &reader, accelmap &rMap) | ||||||||||||
4058 | { | ||||||||||||
4059 | xmlreader::Span name; | ||||||||||||
4060 | int nsId; | ||||||||||||
4061 | |||||||||||||
4062 | OString sProperty; | ||||||||||||
4063 | OString sValue; | ||||||||||||
4064 | OString sModifiers; | ||||||||||||
4065 | |||||||||||||
4066 | while (reader.nextAttribute(&nsId, &name)) | ||||||||||||
4067 | { | ||||||||||||
4068 | if (name == "key") | ||||||||||||
4069 | { | ||||||||||||
4070 | name = reader.getAttributeValue(false); | ||||||||||||
4071 | sValue = OString(name.begin, name.length); | ||||||||||||
4072 | } | ||||||||||||
4073 | else if (name == "signal") | ||||||||||||
4074 | { | ||||||||||||
4075 | name = reader.getAttributeValue(false); | ||||||||||||
4076 | sProperty = OString(name.begin, name.length); | ||||||||||||
4077 | } | ||||||||||||
4078 | else if (name == "modifiers") | ||||||||||||
4079 | { | ||||||||||||
4080 | name = reader.getAttributeValue(false); | ||||||||||||
4081 | sModifiers = OString(name.begin, name.length); | ||||||||||||
4082 | } | ||||||||||||
4083 | } | ||||||||||||
4084 | |||||||||||||
4085 | if (!sProperty.isEmpty() && !sValue.isEmpty()) | ||||||||||||
4086 | { | ||||||||||||
4087 | rMap[sProperty] = std::make_pair(sValue, sModifiers); | ||||||||||||
4088 | } | ||||||||||||
4089 | } | ||||||||||||
4090 | |||||||||||||
4091 | vcl::Window *VclBuilder::get_widget_root() | ||||||||||||
4092 | { | ||||||||||||
4093 | return m_aChildren.empty() ? nullptr : m_aChildren[0].m_pWindow.get(); | ||||||||||||
4094 | } | ||||||||||||
4095 | |||||||||||||
4096 | vcl::Window *VclBuilder::get_by_name(const OString& sID) | ||||||||||||
4097 | { | ||||||||||||
4098 | for (auto const& child : m_aChildren) | ||||||||||||
4099 | { | ||||||||||||
4100 | if (child.m_sID == sID) | ||||||||||||
4101 | return child.m_pWindow; | ||||||||||||
4102 | } | ||||||||||||
4103 | |||||||||||||
4104 | return nullptr; | ||||||||||||
4105 | } | ||||||||||||
4106 | |||||||||||||
4107 | PopupMenu *VclBuilder::get_menu(const OString& sID) | ||||||||||||
4108 | { | ||||||||||||
4109 | for (auto const& menu : m_aMenus) | ||||||||||||
4110 | { | ||||||||||||
4111 | if (menu.m_sID == sID) | ||||||||||||
4112 | return dynamic_cast<PopupMenu*>(menu.m_pMenu.get()); | ||||||||||||
4113 | } | ||||||||||||
4114 | |||||||||||||
4115 | return nullptr; | ||||||||||||
4116 | } | ||||||||||||
4117 | |||||||||||||
4118 | void VclBuilder::set_response(const OString& sID, short nResponse) | ||||||||||||
4119 | { | ||||||||||||
4120 | switch (nResponse) | ||||||||||||
4121 | { | ||||||||||||
4122 | case -5: | ||||||||||||
4123 | nResponse = RET_OK; | ||||||||||||
4124 | break; | ||||||||||||
4125 | case -6: | ||||||||||||
4126 | nResponse = RET_CANCEL; | ||||||||||||
4127 | break; | ||||||||||||
4128 | case -7: | ||||||||||||
4129 | nResponse = RET_CLOSE; | ||||||||||||
4130 | break; | ||||||||||||
4131 | case -8: | ||||||||||||
4132 | nResponse = RET_YES; | ||||||||||||
4133 | break; | ||||||||||||
4134 | case -9: | ||||||||||||
4135 | nResponse = RET_NO; | ||||||||||||
4136 | break; | ||||||||||||
4137 | case -11: | ||||||||||||
4138 | nResponse = RET_HELP; | ||||||||||||
4139 | break; | ||||||||||||
4140 | default: | ||||||||||||
4141 | assert(nResponse >= 100 && "keep non-canned responses in range 100+ to avoid collision with vcl RET_*")(static_cast <bool> (nResponse >= 100 && "keep non-canned responses in range 100+ to avoid collision with vcl RET_*" ) ? void (0) : __assert_fail ("nResponse >= 100 && \"keep non-canned responses in range 100+ to avoid collision with vcl RET_*\"" , "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 4141, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
4142 | break; | ||||||||||||
4143 | } | ||||||||||||
4144 | |||||||||||||
4145 | for (const auto & child : m_aChildren) | ||||||||||||
4146 | { | ||||||||||||
4147 | if (child.m_sID == sID) | ||||||||||||
4148 | { | ||||||||||||
4149 | PushButton* pPushButton = dynamic_cast<PushButton*>(child.m_pWindow.get()); | ||||||||||||
4150 | assert(pPushButton)(static_cast <bool> (pPushButton) ? void (0) : __assert_fail ("pPushButton", "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 4150, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
4151 | Dialog* pDialog = pPushButton->GetParentDialog(); | ||||||||||||
4152 | assert(pDialog)(static_cast <bool> (pDialog) ? void (0) : __assert_fail ("pDialog", "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 4152, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
4153 | pDialog->add_button(pPushButton, nResponse, false); | ||||||||||||
4154 | return; | ||||||||||||
4155 | } | ||||||||||||
4156 | } | ||||||||||||
4157 | |||||||||||||
4158 | assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" , 4158, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||
4159 | } | ||||||||||||
4160 | |||||||||||||
4161 | void VclBuilder::delete_by_name(const OString& sID) | ||||||||||||
4162 | { | ||||||||||||
4163 | auto aI = std::find_if(m_aChildren.begin(), m_aChildren.end(), | ||||||||||||
4164 | [&sID](WinAndId& rItem) { return rItem.m_sID == sID; }); | ||||||||||||
4165 | if (aI != m_aChildren.end()) | ||||||||||||
4166 | { | ||||||||||||
4167 | aI->m_pWindow.disposeAndClear(); | ||||||||||||
4168 | m_aChildren.erase(aI); | ||||||||||||
4169 | } | ||||||||||||
4170 | } | ||||||||||||
4171 | |||||||||||||
4172 | void VclBuilder::delete_by_window(vcl::Window *pWindow) | ||||||||||||
4173 | { | ||||||||||||
4174 | drop_ownership(pWindow); | ||||||||||||
4175 | pWindow->disposeOnce(); | ||||||||||||
4176 | } | ||||||||||||
4177 | |||||||||||||
4178 | void VclBuilder::drop_ownership(const vcl::Window *pWindow) | ||||||||||||
4179 | { | ||||||||||||
4180 | auto aI = std::find_if(m_aChildren.begin(), m_aChildren.end(), | ||||||||||||
4181 | [&pWindow](WinAndId& rItem) { return rItem.m_pWindow == pWindow; }); | ||||||||||||
4182 | if (aI != m_aChildren.end()) | ||||||||||||
4183 | m_aChildren.erase(aI); | ||||||||||||
4184 | } | ||||||||||||
4185 | |||||||||||||
4186 | OString VclBuilder::get_by_window(const vcl::Window *pWindow) const | ||||||||||||
4187 | { | ||||||||||||
4188 | for (auto const& child : m_aChildren) | ||||||||||||
4189 | { | ||||||||||||
4190 | if (child.m_pWindow == pWindow) | ||||||||||||
4191 | return child.m_sID; | ||||||||||||
4192 | } | ||||||||||||
4193 | |||||||||||||
4194 | return OString(); | ||||||||||||
4195 | } | ||||||||||||
4196 | |||||||||||||
4197 | VclBuilder::PackingData VclBuilder::get_window_packing_data(const vcl::Window *pWindow) const | ||||||||||||
4198 | { | ||||||||||||
4199 | //We've stored the return of new Control, some of these get | ||||||||||||
4200 | //border windows placed around them which are what you get | ||||||||||||
4201 | //from GetChild, so scoot up a level if necessary to get the | ||||||||||||
4202 | //window whose position value we have | ||||||||||||
4203 | const vcl::Window *pPropHolder = pWindow->ImplGetWindow(); | ||||||||||||
4204 | |||||||||||||
4205 | for (auto const& child : m_aChildren) | ||||||||||||
4206 | { | ||||||||||||
4207 | if (child.m_pWindow == pPropHolder) | ||||||||||||
4208 | return child.m_aPackingData; | ||||||||||||
4209 | } | ||||||||||||
4210 | |||||||||||||
4211 | return PackingData(); | ||||||||||||
4212 | } | ||||||||||||
4213 | |||||||||||||
4214 | void VclBuilder::set_window_packing_position(const vcl::Window *pWindow, sal_Int32 nPosition) | ||||||||||||
4215 | { | ||||||||||||
4216 | for (auto & child : m_aChildren) | ||||||||||||
4217 | { | ||||||||||||
4218 | if (child.m_pWindow == pWindow) | ||||||||||||
4219 | child.m_aPackingData.m_nPosition = nPosition; | ||||||||||||
4220 | } | ||||||||||||
4221 | } | ||||||||||||
4222 | |||||||||||||
4223 | const VclBuilder::ListStore *VclBuilder::get_model_by_name(const OString& sID) const | ||||||||||||
4224 | { | ||||||||||||
4225 | std::map<OString, ListStore>::const_iterator aI = m_pParserState->m_aModels.find(sID); | ||||||||||||
4226 | if (aI != m_pParserState->m_aModels.end()) | ||||||||||||
4227 | return &(aI->second); | ||||||||||||
4228 | return nullptr; | ||||||||||||
4229 | } | ||||||||||||
4230 | |||||||||||||
4231 | const VclBuilder::TextBuffer *VclBuilder::get_buffer_by_name(const OString& sID) const | ||||||||||||
4232 | { | ||||||||||||
4233 | std::map<OString, TextBuffer>::const_iterator aI = m_pParserState->m_aTextBuffers.find(sID); | ||||||||||||
4234 | if (aI != m_pParserState->m_aTextBuffers.end()) | ||||||||||||
4235 | return &(aI->second); | ||||||||||||
4236 | return nullptr; | ||||||||||||
4237 | } | ||||||||||||
4238 | |||||||||||||
4239 | const VclBuilder::Adjustment *VclBuilder::get_adjustment_by_name(const OString& sID) const | ||||||||||||
4240 | { | ||||||||||||
4241 | std::map<OString, Adjustment>::const_iterator aI = m_pParserState->m_aAdjustments.find(sID); | ||||||||||||
4242 | if (aI != m_pParserState->m_aAdjustments.end()) | ||||||||||||
4243 | return &(aI->second); | ||||||||||||
4244 | return nullptr; | ||||||||||||
4245 | } | ||||||||||||
4246 | |||||||||||||
4247 | void VclBuilder::mungeModel(ComboBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId) | ||||||||||||
4248 | { | ||||||||||||
4249 | for (auto const& entry : rStore.m_aEntries) | ||||||||||||
4250 | { | ||||||||||||
4251 | const ListStore::row &rRow = entry; | ||||||||||||
4252 | sal_uInt16 nEntry = rTarget.InsertEntry(rRow[0]); | ||||||||||||
4253 | if (rRow.size() > 1) | ||||||||||||
4254 | { | ||||||||||||
4255 | if (m_bLegacy) | ||||||||||||
4256 | { | ||||||||||||
4257 | sal_IntPtr nValue = rRow[1].toInt32(); | ||||||||||||
4258 | rTarget.SetEntryData(nEntry, reinterpret_cast<void*>(nValue)); | ||||||||||||
4259 | } | ||||||||||||
4260 | else | ||||||||||||
4261 | { | ||||||||||||
4262 | if (!rRow[1].isEmpty()) | ||||||||||||
4263 | { | ||||||||||||
4264 | m_aUserData.emplace_back(std::make_unique<OUString>(rRow[1])); | ||||||||||||
4265 | rTarget.SetEntryData(nEntry, m_aUserData.back().get()); | ||||||||||||
4266 | } | ||||||||||||
4267 | } | ||||||||||||
4268 | } | ||||||||||||
4269 | } | ||||||||||||
4270 | if (nActiveId < rStore.m_aEntries.size()) | ||||||||||||
4271 | rTarget.SelectEntryPos(nActiveId); | ||||||||||||
4272 | } | ||||||||||||
4273 | |||||||||||||
4274 | void VclBuilder::mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId) | ||||||||||||
4275 | { | ||||||||||||
4276 | for (auto const& entry : rStore.m_aEntries) | ||||||||||||
4277 | { | ||||||||||||
4278 | const ListStore::row &rRow = entry; | ||||||||||||
4279 | sal_uInt16 nEntry = rTarget.InsertEntry(rRow[0]); | ||||||||||||
4280 | if (rRow.size() > 1) | ||||||||||||
4281 | { | ||||||||||||
4282 | if (m_bLegacy) | ||||||||||||
4283 | { | ||||||||||||
4284 | sal_IntPtr nValue = rRow[1].toInt32(); | ||||||||||||
4285 | rTarget.SetEntryData(nEntry, reinterpret_cast<void*>(nValue)); | ||||||||||||
4286 | } | ||||||||||||
4287 | else | ||||||||||||
4288 | { | ||||||||||||
4289 | if (!rRow[1].isEmpty()) | ||||||||||||
4290 | { | ||||||||||||
4291 | m_aUserData.emplace_back(std::make_unique<OUString>(rRow[1])); | ||||||||||||
4292 | rTarget.SetEntryData(nEntry, m_aUserData.back().get()); | ||||||||||||
4293 | } | ||||||||||||
4294 | } | ||||||||||||
4295 | } | ||||||||||||
4296 | } | ||||||||||||
4297 | if (nActiveId < rStore.m_aEntries.size()) | ||||||||||||
4298 | rTarget.SelectEntryPos(nActiveId); | ||||||||||||
4299 | } | ||||||||||||
4300 | |||||||||||||
4301 | void VclBuilder::mungeModel(SvTabListBox& rTarget, const ListStore &rStore, sal_uInt16 nActiveId) | ||||||||||||
4302 | { | ||||||||||||
4303 | for (auto const& entry : rStore.m_aEntries) | ||||||||||||
4304 | { | ||||||||||||
4305 | const ListStore::row &rRow = entry; | ||||||||||||
4306 | auto pEntry = rTarget.InsertEntry(rRow[0]); | ||||||||||||
4307 | if (rRow.size() > 1) | ||||||||||||
4308 | { | ||||||||||||
4309 | if (m_bLegacy) | ||||||||||||
4310 | { | ||||||||||||
4311 | sal_IntPtr nValue = rRow[1].toInt32(); | ||||||||||||
4312 | pEntry->SetUserData(reinterpret_cast<void*>(nValue)); | ||||||||||||
4313 | } | ||||||||||||
4314 | else | ||||||||||||
4315 | { | ||||||||||||
4316 | if (!rRow[1].isEmpty()) | ||||||||||||
4317 | { | ||||||||||||
4318 | m_aUserData.emplace_back(std::make_unique<OUString>(rRow[1])); | ||||||||||||
4319 | pEntry->SetUserData(m_aUserData.back().get()); | ||||||||||||
4320 | } | ||||||||||||
4321 | } | ||||||||||||
4322 | } | ||||||||||||
4323 | } | ||||||||||||
4324 | if (nActiveId < rStore.m_aEntries.size()) | ||||||||||||
4325 | { | ||||||||||||
4326 | SvTreeListEntry* pEntry = rTarget.GetEntry(nullptr, nActiveId); | ||||||||||||
4327 | rTarget.Select(pEntry); | ||||||||||||
4328 | } | ||||||||||||
4329 | } | ||||||||||||
4330 | |||||||||||||
4331 | void VclBuilder::mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rAdjustment) | ||||||||||||
4332 | { | ||||||||||||
4333 | int nMul = rtl_math_pow10Exp(1, rTarget.GetDecimalDigits()); | ||||||||||||
4334 | |||||||||||||
4335 | for (auto const& elem : rAdjustment) | ||||||||||||
4336 | { | ||||||||||||
4337 | const OString &rKey = elem.first; | ||||||||||||
4338 | const OUString &rValue = elem.second; | ||||||||||||
4339 | |||||||||||||
4340 | if (rKey == "upper") | ||||||||||||
4341 | { | ||||||||||||
4342 | sal_Int64 nUpper = rValue.toDouble() * nMul; | ||||||||||||
4343 | rTarget.SetMax(nUpper); | ||||||||||||
4344 | rTarget.SetLast(nUpper); | ||||||||||||
4345 | } | ||||||||||||
4346 | else if (rKey == "lower") | ||||||||||||
4347 | { | ||||||||||||
4348 | sal_Int64 nLower = rValue.toDouble() * nMul; | ||||||||||||
4349 | rTarget.SetMin(nLower); | ||||||||||||
4350 | rTarget.SetFirst(nLower); | ||||||||||||
4351 | } | ||||||||||||
4352 | else if (rKey == "value") | ||||||||||||
4353 | { | ||||||||||||
4354 | sal_Int64 nValue = rValue.toDouble() * nMul; | ||||||||||||
4355 | rTarget.SetValue(nValue); | ||||||||||||
4356 | } | ||||||||||||
4357 | else if (rKey == "step-increment") | ||||||||||||
4358 | { | ||||||||||||
4359 | sal_Int64 nSpinSize = rValue.toDouble() * nMul; | ||||||||||||
4360 | rTarget.SetSpinSize(nSpinSize); | ||||||||||||
4361 | } | ||||||||||||
4362 | else | ||||||||||||
4363 | { | ||||||||||||
4364 | SAL_INFO("vcl.builder", "unhandled property :" << rKey)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled property :" << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4364" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property :" << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property :" << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4364" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled property :" << rKey) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4364" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property :" << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property :" << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4364" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
4365 | } | ||||||||||||
4366 | } | ||||||||||||
4367 | } | ||||||||||||
4368 | |||||||||||||
4369 | void VclBuilder::mungeAdjustment(FormattedField &rTarget, const Adjustment &rAdjustment) | ||||||||||||
4370 | { | ||||||||||||
4371 | double nMaxValue = 0, nMinValue = 0, nValue = 0, nSpinSize = 0; | ||||||||||||
4372 | |||||||||||||
4373 | for (auto const& elem : rAdjustment) | ||||||||||||
4374 | { | ||||||||||||
4375 | const OString &rKey = elem.first; | ||||||||||||
4376 | const OUString &rValue = elem.second; | ||||||||||||
4377 | |||||||||||||
4378 | if (rKey == "upper") | ||||||||||||
4379 | nMaxValue = rValue.toDouble(); | ||||||||||||
4380 | else if (rKey == "lower") | ||||||||||||
4381 | nMinValue = rValue.toDouble(); | ||||||||||||
4382 | else if (rKey == "value") | ||||||||||||
4383 | nValue = rValue.toDouble(); | ||||||||||||
4384 | else if (rKey == "step-increment") | ||||||||||||
4385 | nSpinSize = rValue.toDouble(); | ||||||||||||
4386 | else | ||||||||||||
4387 | SAL_INFO("vcl.builder", "unhandled property :" << rKey)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled property :" << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4387" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property :" << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property :" << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4387" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled property :" << rKey) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4387" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property :" << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property :" << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4387" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
4388 | } | ||||||||||||
4389 | |||||||||||||
4390 | Formatter& rFormatter = rTarget.GetFormatter(); | ||||||||||||
4391 | rFormatter.SetMinValue(nMinValue); | ||||||||||||
4392 | rFormatter.SetMaxValue(nMaxValue); | ||||||||||||
4393 | rFormatter.SetValue(nValue); | ||||||||||||
4394 | rFormatter.SetSpinSize(nSpinSize); | ||||||||||||
4395 | } | ||||||||||||
4396 | |||||||||||||
4397 | void VclBuilder::mungeAdjustment(ScrollBar &rTarget, const Adjustment &rAdjustment) | ||||||||||||
4398 | { | ||||||||||||
4399 | for (auto const& elem : rAdjustment) | ||||||||||||
4400 | { | ||||||||||||
4401 | const OString &rKey = elem.first; | ||||||||||||
4402 | const OUString &rValue = elem.second; | ||||||||||||
4403 | |||||||||||||
4404 | if (rKey == "upper") | ||||||||||||
4405 | rTarget.SetRangeMax(rValue.toInt32()); | ||||||||||||
4406 | else if (rKey == "lower") | ||||||||||||
4407 | rTarget.SetRangeMin(rValue.toInt32()); | ||||||||||||
4408 | else if (rKey == "value") | ||||||||||||
4409 | rTarget.SetThumbPos(rValue.toInt32()); | ||||||||||||
4410 | else if (rKey == "step-increment") | ||||||||||||
4411 | rTarget.SetLineSize(rValue.toInt32()); | ||||||||||||
4412 | else if (rKey == "page-increment") | ||||||||||||
4413 | rTarget.SetPageSize(rValue.toInt32()); | ||||||||||||
4414 | else | ||||||||||||
4415 | { | ||||||||||||
4416 | SAL_INFO("vcl.builder", "unhandled property :" << rKey)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled property :" << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4416" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property :" << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property :" << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4416" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled property :" << rKey) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4416" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property :" << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property :" << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4416" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
4417 | } | ||||||||||||
4418 | } | ||||||||||||
4419 | } | ||||||||||||
4420 | |||||||||||||
4421 | void VclBuilder::mungeAdjustment(Slider& rTarget, const Adjustment& rAdjustment) | ||||||||||||
4422 | { | ||||||||||||
4423 | for (auto const& elem : rAdjustment) | ||||||||||||
4424 | { | ||||||||||||
4425 | const OString &rKey = elem.first; | ||||||||||||
4426 | const OUString &rValue = elem.second; | ||||||||||||
4427 | |||||||||||||
4428 | if (rKey == "upper") | ||||||||||||
4429 | rTarget.SetRangeMax(rValue.toInt32()); | ||||||||||||
4430 | else if (rKey == "lower") | ||||||||||||
4431 | rTarget.SetRangeMin(rValue.toInt32()); | ||||||||||||
4432 | else if (rKey == "value") | ||||||||||||
4433 | rTarget.SetThumbPos(rValue.toInt32()); | ||||||||||||
4434 | else if (rKey == "step-increment") | ||||||||||||
4435 | rTarget.SetLineSize(rValue.toInt32()); | ||||||||||||
4436 | else if (rKey == "page-increment") | ||||||||||||
4437 | rTarget.SetPageSize(rValue.toInt32()); | ||||||||||||
4438 | else | ||||||||||||
4439 | { | ||||||||||||
4440 | SAL_INFO("vcl.builder", "unhandled property :" << rKey)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled property :" << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4440" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property :" << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property :" << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4440" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled property :" << rKey) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4440" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property :" << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property :" << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4440" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
4441 | } | ||||||||||||
4442 | } | ||||||||||||
4443 | } | ||||||||||||
4444 | |||||||||||||
4445 | void VclBuilder::mungeTextBuffer(VclMultiLineEdit &rTarget, const TextBuffer &rTextBuffer) | ||||||||||||
4446 | { | ||||||||||||
4447 | for (auto const& elem : rTextBuffer) | ||||||||||||
4448 | { | ||||||||||||
4449 | const OString &rKey = elem.first; | ||||||||||||
4450 | const OUString &rValue = elem.second; | ||||||||||||
4451 | |||||||||||||
4452 | if (rKey == "text") | ||||||||||||
4453 | rTarget.SetText(rValue); | ||||||||||||
4454 | else | ||||||||||||
4455 | { | ||||||||||||
4456 | SAL_INFO("vcl.builder", "unhandled property :" << rKey)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO , "vcl.builder")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult ( ::sal::detail::StreamStart() << "unhandled property :" << rKey) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4456" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property :" << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property :" << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4456" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "unhandled property :" << rKey) == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4456" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "unhandled property :" << rKey ), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "unhandled property :" << rKey; ::sal::detail ::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("vcl.builder"), ("/home/maarten/src/libreoffice/core/vcl/source/window/builder.cxx" ":" "4456" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||||||
4457 | } | ||||||||||||
4458 | } | ||||||||||||
4459 | } | ||||||||||||
4460 | |||||||||||||
4461 | VclBuilder::ParserState::ParserState() | ||||||||||||
4462 | : m_nLastToolbarId(0) | ||||||||||||
4463 | , m_nLastMenuItemId(0) | ||||||||||||
4464 | {} | ||||||||||||
4465 | |||||||||||||
4466 | VclBuilder::MenuAndId::MenuAndId(const OString &rId, Menu *pMenu) | ||||||||||||
4467 | : m_sID(rId) | ||||||||||||
4468 | , m_pMenu(pMenu) | ||||||||||||
4469 | {} | ||||||||||||
4470 | |||||||||||||
4471 | /* 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 |