LibreOffice Module vcl (master)  1
builder.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #include <config_feature_desktop.h>
11 #include <config_options.h>
12 
13 #include <memory>
14 #include <string_view>
15 #include <unordered_map>
16 #include <com/sun/star/accessibility/AccessibleRole.hpp>
17 
18 #include <comphelper/lok.hxx>
19 #include <i18nutil/unicode.hxx>
20 #include <jsdialog/enabled.hxx>
21 #include <officecfg/Office/Common.hxx>
22 #include <osl/module.hxx>
23 #include <sal/log.hxx>
25 #include <unotools/resmgr.hxx>
26 #include <vcl/builder.hxx>
27 #include <vcl/dialoghelper.hxx>
28 #include <vcl/menu.hxx>
29 #include <vcl/toolkit/button.hxx>
30 #include <vcl/toolkit/dialog.hxx>
31 #include <vcl/toolkit/edit.hxx>
32 #include <vcl/toolkit/field.hxx>
33 #include <vcl/fieldvalues.hxx>
34 #include <vcl/toolkit/fmtfield.hxx>
35 #include <vcl/toolkit/fixed.hxx>
37 #include <vcl/headbar.hxx>
39 #include <vcl/toolkit/ivctrl.hxx>
40 #include <vcl/layout.hxx>
41 #include <vcl/toolkit/lstbox.hxx>
42 #include <vcl/toolkit/menubtn.hxx>
43 #include <vcl/mnemonic.hxx>
44 #include <vcl/toolkit/prgsbar.hxx>
45 #include <vcl/scrbar.hxx>
46 #include <vcl/split.hxx>
47 #include <vcl/svapp.hxx>
48 #include <vcl/toolkit/svtabbx.hxx>
49 #include <vcl/tabctrl.hxx>
50 #include <vcl/tabpage.hxx>
51 #include <vcl/toolkit/throbber.hxx>
52 #include <vcl/toolbox.hxx>
54 #include <vcl/toolkit/vclmedit.hxx>
55 #include <vcl/settings.hxx>
56 #include <slider.hxx>
57 #include <vcl/weld.hxx>
58 #include <vcl/weldutils.hxx>
60 #include <iconview.hxx>
61 #include <svdata.hxx>
62 #include <bitmaps.hlst>
63 #include <managedmenubutton.hxx>
64 #include <messagedialog.hxx>
65 #include <ContextVBox.hxx>
66 #include <DropdownBox.hxx>
67 #include <IPrioritable.hxx>
68 #include <OptionalBox.hxx>
69 #include <PriorityMergedHBox.hxx>
70 #include <PriorityHBox.hxx>
71 #include <window.h>
72 #include <xmlreader/xmlreader.hxx>
73 #include <desktop/crashreport.hxx>
74 #include <calendar.hxx>
75 #include <menutogglebutton.hxx>
76 #include <salinst.hxx>
77 #include <strings.hrc>
78 #include <treeglue.hxx>
79 #include <tools/diagnose_ex.h>
80 #include <verticaltabctrl.hxx>
81 #include <wizdlg.hxx>
82 #include <tools/svlibrary.h>
84 
85 #if defined(DISABLE_DYNLOADING) || defined(LINUX)
86 #include <dlfcn.h>
87 #endif
88 
89 static bool toBool(std::string_view rValue)
90 {
91  return (!rValue.empty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1'));
92 }
93 
94 namespace
95 {
96  OUString mapStockToImageResource(std::u16string_view sType)
97  {
98  if (sType == u"view-refresh")
99  return SV_RESID_BITMAP_REFRESH;
100  else if (sType == u"dialog-error")
101  return IMG_ERROR;
102  else if (sType == u"list-add")
103  return IMG_ADD;
104  else if (sType == u"list-remove")
105  return IMG_REMOVE;
106  else if (sType == u"edit-copy")
107  return IMG_COPY;
108  else if (sType == u"edit-paste")
109  return IMG_PASTE;
110  else if (sType == u"open-menu-symbolic")
111  return IMG_MENU;
112  else if (sType == u"window-close-symbolic")
113  return SV_RESID_BITMAP_CLOSEDOC;
114  else if (sType == u"x-office-calendar")
115  return IMG_CALENDAR;
116  return OUString();
117  }
118 
119 }
120 
121 SymbolType VclBuilder::mapStockToSymbol(std::u16string_view sType)
122 {
124  if (sType == u"media-skip-forward")
125  eRet = SymbolType::NEXT;
126  else if (sType == u"media-skip-backward")
127  eRet = SymbolType::PREV;
128  else if (sType == u"media-playback-start")
129  eRet = SymbolType::PLAY;
130  else if (sType == u"media-playback-stop")
131  eRet = SymbolType::STOP;
132  else if (sType == u"go-first")
133  eRet = SymbolType::FIRST;
134  else if (sType == u"go-last")
135  eRet = SymbolType::LAST;
136  else if (sType == u"go-previous")
137  eRet = SymbolType::ARROW_LEFT;
138  else if (sType == u"go-next")
140  else if (sType == u"go-up")
141  eRet = SymbolType::ARROW_UP;
142  else if (sType == u"go-down")
143  eRet = SymbolType::ARROW_DOWN;
144  else if (sType == u"missing-image")
145  eRet = SymbolType::IMAGE;
146  else if (sType == u"help-browser" || sType == u"help-browser-symbolic")
147  eRet = SymbolType::HELP;
148  else if (sType == u"window-close")
149  eRet = SymbolType::CLOSE;
150  else if (sType == u"document-new")
151  eRet = SymbolType::PLUS;
152  else if (sType == u"pan-down-symbolic")
153  eRet = SymbolType::SPIN_DOWN;
154  else if (sType == u"pan-up-symbolic")
155  eRet = SymbolType::SPIN_UP;
156  else if (!mapStockToImageResource(sType).isEmpty())
157  eRet = SymbolType::IMAGE;
158  return eRet;
159 }
160 
161 namespace
162 {
163  void setupFromActionName(Button *pButton, VclBuilder::stringmap &rMap, const css::uno::Reference<css::frame::XFrame>& rFrame);
164 
165 #if defined SAL_LOG_WARN
166  bool isButtonType(WindowType nType)
167  {
168  return nType == WindowType::PUSHBUTTON ||
169  nType == WindowType::OKBUTTON ||
170  nType == WindowType::CANCELBUTTON ||
171  nType == WindowType::HELPBUTTON ||
172  nType == WindowType::IMAGEBUTTON ||
173  nType == WindowType::MENUBUTTON ||
174  nType == WindowType::MOREBUTTON ||
175  nType == WindowType::SPINBUTTON;
176  }
177 #endif
178 
179 }
180 
181 weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString &rUIFile, bool bMobile)
182 {
183  bool bUseJSBuilder = false;
184 
186  bUseJSBuilder = jsdialog::isBuilderEnabled(rUIFile, bMobile);
187 
188  if (bUseJSBuilder)
190  else
191  return ImplGetSVData()->mpDefInst->CreateBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile);
192 }
193 
194 weld::Builder* Application::CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId)
195 {
196  // Notebookbar sub controls
198  {
199  return JSInstanceBuilder::CreateNotebookbarBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile, css::uno::Reference<css::frame::XFrame>(), nLOKWindowId);
200  }
201  else if (comphelper::LibreOfficeKit::isActive() && (rUIFile == "modules/scalc/ui/filterdropdown.ui"))
202  {
204  }
205 
206  return ImplGetSVData()->mpDefInst->CreateInterimBuilder(pParent, AllSettings::GetUIRootDir(), rUIFile, bAllowCycleFocusOut, nLOKWindowId);
207 }
208 
210  VclButtonsType eButtonType, const OUString& rPrimaryMessage,
211  bool bMobile)
212 {
213  if (bMobile)
214  return JSInstanceBuilder::CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage);
215  else
216  return ImplGetSVData()->mpDefInst->CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage);
217 }
218 
219 weld::Window* Application::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow)
220 {
221  return ImplGetSVData()->mpDefInst->GetFrameWeld(rWindow);
222 }
223 
224 namespace weld
225 {
227  {
228  const FieldUnitStringList& rList = ImplGetFieldUnits();
229  // return unit's default string (ie, the first one )
230  auto it = std::find_if(
231  rList.begin(), rList.end(),
232  [&rUnit](const std::pair<OUString, FieldUnit>& rItem) { return rItem.second == rUnit; });
233  if (it != rList.end())
234  return it->first;
235 
236  return OUString();
237  }
238 
239  IMPL_LINK_NOARG(MetricSpinButton, spin_button_value_changed, SpinButton&, void)
240  {
241  signal_value_changed();
242  }
243 
244  IMPL_LINK(MetricSpinButton, spin_button_output, SpinButton&, rSpinButton, void)
245  {
246  OUString sNewText(format_number(rSpinButton.get_value()));
247  if (sNewText != rSpinButton.get_text())
248  rSpinButton.set_text(sNewText);
249  }
250 
252  {
253  int min, max;
254  m_xSpinButton->get_range(min, max);
255  auto width = std::max(m_xSpinButton->get_pixel_size(format_number(min)).Width(),
256  m_xSpinButton->get_pixel_size(format_number(max)).Width());
257  int chars = ceil(width / m_xSpinButton->get_approximate_digit_width());
258  m_xSpinButton->set_width_chars(chars);
259  }
260 
261  unsigned int SpinButton::Power10(unsigned int n)
262  {
263  unsigned int nValue = 1;
264  for (unsigned int i = 0; i < n; ++i)
265  nValue *= 10;
266  return nValue;
267  }
268 
269  int SpinButton::denormalize(int nValue) const
270  {
271  const int nFactor = Power10(get_digits());
272 
273  if ((nValue < (SAL_MIN_INT32 + nFactor)) || (nValue > (SAL_MAX_INT32 - nFactor)))
274  {
275  return nValue / nFactor;
276  }
277 
278  const int nHalf = nFactor / 2;
279 
280  if (nValue < 0)
281  return (nValue - nHalf) / nFactor;
282  return (nValue + nHalf) / nFactor;
283  }
284 
285  OUString MetricSpinButton::format_number(int nValue) const
286  {
287  OUString aStr;
288 
290 
291  unsigned int nDecimalDigits = m_xSpinButton->get_digits();
292  //pawn percent off to icu to decide whether percent is separated from its number for this locale
293  if (m_eSrcUnit == FieldUnit::PERCENT)
294  {
295  double fValue = nValue;
296  fValue /= SpinButton::Power10(nDecimalDigits);
297  aStr = unicode::formatPercent(fValue, rLocaleData.getLanguageTag());
298  }
299  else
300  {
301  aStr = rLocaleData.getNum(nValue, nDecimalDigits, true, true);
302  OUString aSuffix = MetricToString(m_eSrcUnit);
303  if (m_eSrcUnit != FieldUnit::NONE && m_eSrcUnit != FieldUnit::DEGREE && m_eSrcUnit != FieldUnit::INCH && m_eSrcUnit != FieldUnit::FOOT)
304  aStr += " ";
305  if (m_eSrcUnit == FieldUnit::INCH)
306  {
307  OUString sDoublePrime = u"\u2033";
308  if (aSuffix != "\"" && aSuffix != sDoublePrime)
309  aStr += " ";
310  else
311  aSuffix = sDoublePrime;
312  }
313  else if (m_eSrcUnit == FieldUnit::FOOT)
314  {
315  OUString sPrime = u"\u2032";
316  if (aSuffix != "'" && aSuffix != sPrime)
317  aStr += " ";
318  else
319  aSuffix = sPrime;
320  }
321 
322  assert(m_eSrcUnit != FieldUnit::PERCENT);
323  aStr += aSuffix;
324  }
325 
326  return aStr;
327  }
328 
329  void MetricSpinButton::set_digits(unsigned int digits)
330  {
331  int step, page;
332  get_increments(step, page, m_eSrcUnit);
333  int value = get_value(m_eSrcUnit);
334  m_xSpinButton->set_digits(digits);
335  set_increments(step, page, m_eSrcUnit);
336  set_value(value, m_eSrcUnit);
338  }
339 
341  {
342  if (eUnit != m_eSrcUnit)
343  {
344  int step, page;
345  get_increments(step, page, m_eSrcUnit);
346  int value = get_value(m_eSrcUnit);
347  m_eSrcUnit = eUnit;
348  set_increments(step, page, m_eSrcUnit);
349  set_value(value, m_eSrcUnit);
350  spin_button_output(*m_xSpinButton);
352  }
353  }
354 
355  int MetricSpinButton::ConvertValue(int nValue, FieldUnit eInUnit, FieldUnit eOutUnit) const
356  {
357  auto nRet = vcl::ConvertValue(nValue, 0, m_xSpinButton->get_digits(), eInUnit, eOutUnit);
358  if (nRet > SAL_MAX_INT32)
359  nRet = SAL_MAX_INT32;
360  else if (nRet < SAL_MIN_INT32)
361  nRet = SAL_MIN_INT32;
362  return nRet;
363  }
364 
365  IMPL_LINK(MetricSpinButton, spin_button_input, int*, result, bool)
366  {
368  double fResult(0.0);
369  bool bRet = vcl::TextToValue(get_text(), fResult, 0, m_xSpinButton->get_digits(), rLocaleData, m_eSrcUnit);
370  if (bRet)
371  {
372  if (fResult > SAL_MAX_INT32)
373  fResult = SAL_MAX_INT32;
374  else if (fResult < SAL_MIN_INT32)
375  fResult = SAL_MIN_INT32;
376  *result = fResult;
377  }
378  return bRet;
379  }
380 
381  EntryTreeView::EntryTreeView(std::unique_ptr<Entry> xEntry, std::unique_ptr<TreeView> xTreeView)
382  : m_xEntry(std::move(xEntry))
383  , m_xTreeView(std::move(xTreeView))
384  {
385  m_xTreeView->connect_changed(LINK(this, EntryTreeView, ClickHdl));
386  m_xEntry->connect_changed(LINK(this, EntryTreeView, ModifyHdl));
387  }
388 
389  IMPL_LINK(EntryTreeView, ClickHdl, weld::TreeView&, rView, void)
390  {
391  m_xEntry->set_text(rView.get_selected_text());
392  m_aChangeHdl.Call(*this);
393  }
394 
396  {
397  m_aChangeHdl.Call(*this);
398  }
399 
401  {
402  int nHeight = nRows == -1 ? -1 : m_xTreeView->get_height_rows(nRows);
403  m_xTreeView->set_size_request(m_xTreeView->get_size_request().Width(), nHeight);
404  }
405 
406  size_t GetAbsPos(const weld::TreeView& rTreeView, const weld::TreeIter& rIter)
407  {
408  size_t nAbsPos = 0;
409 
410  std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator(&rIter));
411  if (!rTreeView.get_iter_first(*xEntry))
412  xEntry.reset();
413 
414  while (xEntry && rTreeView.iter_compare(*xEntry, rIter) != 0)
415  {
416  if (!rTreeView.iter_next(*xEntry))
417  xEntry.reset();
418  nAbsPos++;
419  }
420 
421  return nAbsPos;
422  }
423 
424  bool IsEntryVisible(const weld::TreeView& rTreeView, const weld::TreeIter& rIter)
425  {
426  // short circuit for the common case
427  if (rTreeView.get_iter_depth(rIter) == 0)
428  return true;
429 
430  std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator(&rIter));
431  bool bRetVal = false;
432  do
433  {
434  if (rTreeView.get_iter_depth(*xEntry) == 0)
435  {
436  bRetVal = true;
437  break;
438  }
439  } while (rTreeView.iter_parent(*xEntry) && rTreeView.get_row_expanded(*xEntry));
440  return bRetVal;
441  }
442 }
443 
444 VclBuilder::VclBuilder(vcl::Window* pParent, const OUString& sUIDir, const OUString& sUIFile,
445  const OString& sID, const css::uno::Reference<css::frame::XFrame>& rFrame,
446  bool bLegacy, const NotebookBarAddonsItem* pNotebookBarAddonsItem)
447  : m_pNotebookBarAddonsItem(pNotebookBarAddonsItem
448  ? new NotebookBarAddonsItem(*pNotebookBarAddonsItem)
449  : new NotebookBarAddonsItem{})
450  , m_sID(sID)
451  , m_sHelpRoot(OUStringToOString(sUIFile, RTL_TEXTENCODING_UTF8))
452  , m_pStringReplace(Translate::GetReadStringHook())
453  , m_pParent(pParent)
454  , m_bToplevelParentFound(false)
455  , m_bLegacy(bLegacy)
456  , m_pParserState(new ParserState)
457  , m_xFrame(rFrame)
458 {
459  m_bToplevelHasDeferredInit = pParent &&
460  ((pParent->IsSystemWindow() && static_cast<SystemWindow*>(pParent)->isDeferredInit()) ||
461  (pParent->IsDockingWindow() && static_cast<DockingWindow*>(pParent)->isDeferredInit()));
462  m_bToplevelHasDeferredProperties = m_bToplevelHasDeferredInit;
463 
464  sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.');
465  if (nIdx != -1)
466  m_sHelpRoot = m_sHelpRoot.copy(0, nIdx);
467  m_sHelpRoot += "/";
468 
469  OUString sUri = sUIDir + sUIFile;
470 
471  try
472  {
473  xmlreader::XmlReader reader(sUri);
474 
475  handleChild(pParent, nullptr, reader);
476  }
477  catch (const css::uno::Exception &rExcept)
478  {
479  DBG_UNHANDLED_EXCEPTION("vcl.builder", "Unable to read .ui file");
480  CrashReporter::addKeyValue("VclBuilderException", "Unable to read .ui file: " + rExcept.Message, CrashReporter::Write);
481  throw;
482  }
483 
484  //Set Mnemonic widgets when everything has been imported
485  for (auto const& mnemonicWidget : m_pParserState->m_aMnemonicWidgetMaps)
486  {
487  FixedText *pOne = get<FixedText>(mnemonicWidget.m_sID);
488  vcl::Window *pOther = get(mnemonicWidget.m_sValue.toUtf8());
489  SAL_WARN_IF(!pOne || !pOther, "vcl", "missing either source " << mnemonicWidget.m_sID
490  << " or target " << mnemonicWidget.m_sValue << " member of Mnemonic Widget Mapping");
491  if (pOne && pOther)
492  pOne->set_mnemonic_widget(pOther);
493  }
494 
495  //Set a11y relations and role when everything has been imported
496  for (auto const& elemAtk : m_pParserState->m_aAtkInfo)
497  {
498  vcl::Window *pSource = elemAtk.first;
499  const stringmap &rMap = elemAtk.second;
500 
501  for (auto const& elemMap : rMap)
502  {
503  const OString &rType = elemMap.first;
504  const OUString &rParam = elemMap.second;
505  if (rType == "role")
506  {
507  sal_Int16 role = BuilderUtils::getRoleFromName(rParam.toUtf8());
508  if (role != com::sun::star::accessibility::AccessibleRole::UNKNOWN)
509  pSource->SetAccessibleRole(role);
510  }
511  else
512  {
513  vcl::Window *pTarget = get(rParam.toUtf8());
514  SAL_WARN_IF(!pTarget, "vcl", "missing parameter of a11y relation: " << rParam);
515  if (!pTarget)
516  continue;
517  if (rType == "labelled-by")
518  pSource->SetAccessibleRelationLabeledBy(pTarget);
519  else if (rType == "label-for")
520  pSource->SetAccessibleRelationLabelFor(pTarget);
521  else if (rType == "member-of")
522  pSource->SetAccessibleRelationMemberOf(pTarget);
523  else
524  {
525  SAL_WARN("vcl.builder", "unhandled a11y relation :" << rType);
526  }
527  }
528  }
529  }
530 
531  //Set radiobutton groups when everything has been imported
532  for (auto const& elem : m_pParserState->m_aGroupMaps)
533  {
534  RadioButton *pOne = get<RadioButton>(elem.m_sID);
535  RadioButton *pOther = get<RadioButton>(elem.m_sValue);
536  SAL_WARN_IF(!pOne || !pOther, "vcl", "missing member of radiobutton group");
537  if (pOne && pOther)
538  {
539  if (m_bLegacy)
540  pOne->group(*pOther);
541  else
542  {
543  pOther->group(*pOne);
544  std::stable_sort(pOther->m_xGroup->begin(), pOther->m_xGroup->end(), sortIntoBestTabTraversalOrder(this));
545  }
546  }
547  }
548 
549  //Set ComboBox models when everything has been imported
550  for (auto const& elem : m_pParserState->m_aModelMaps)
551  {
552  vcl::Window* pTarget = get(elem.m_sID);
553  ListBox *pListBoxTarget = dynamic_cast<ListBox*>(pTarget);
554  ComboBox *pComboBoxTarget = dynamic_cast<ComboBox*>(pTarget);
555  SvTabListBox *pTreeBoxTarget = dynamic_cast<SvTabListBox*>(pTarget);
556  // pStore may be empty
557  const ListStore *pStore = get_model_by_name(elem.m_sValue.toUtf8());
558  SAL_WARN_IF(!pListBoxTarget && !pComboBoxTarget && !pTreeBoxTarget && !dynamic_cast<IconView*>(pTarget), "vcl", "missing elements of combobox");
559  if (pListBoxTarget && pStore)
560  mungeModel(*pListBoxTarget, *pStore, elem.m_nActiveId);
561  else if (pComboBoxTarget && pStore)
562  mungeModel(*pComboBoxTarget, *pStore, elem.m_nActiveId);
563  else if (pTreeBoxTarget && pStore)
564  mungeModel(*pTreeBoxTarget, *pStore, elem.m_nActiveId);
565  }
566 
567  //Set TextView buffers when everything has been imported
568  for (auto const& elem : m_pParserState->m_aTextBufferMaps)
569  {
570  VclMultiLineEdit *pTarget = get<VclMultiLineEdit>(elem.m_sID);
571  const TextBuffer *pBuffer = get_buffer_by_name(elem.m_sValue.toUtf8());
572  SAL_WARN_IF(!pTarget || !pBuffer, "vcl", "missing elements of textview/textbuffer");
573  if (pTarget && pBuffer)
574  mungeTextBuffer(*pTarget, *pBuffer);
575  }
576 
577  //Set SpinButton adjustments when everything has been imported
578  for (auto const& elem : m_pParserState->m_aNumericFormatterAdjustmentMaps)
579  {
580  NumericFormatter *pTarget = dynamic_cast<NumericFormatter*>(get(elem.m_sID));
581  const Adjustment *pAdjustment = get_adjustment_by_name(elem.m_sValue.toUtf8());
582  SAL_WARN_IF(!pTarget, "vcl", "missing NumericFormatter element of spinbutton/adjustment");
583  SAL_WARN_IF(!pAdjustment, "vcl", "missing Adjustment element of spinbutton/adjustment");
584  if (pTarget && pAdjustment)
585  mungeAdjustment(*pTarget, *pAdjustment);
586  }
587 
588  for (auto const& elem : m_pParserState->m_aFormattedFormatterAdjustmentMaps)
589  {
590  FormattedField *pTarget = dynamic_cast<FormattedField*>(get(elem.m_sID));
591  const Adjustment *pAdjustment = get_adjustment_by_name(elem.m_sValue.toUtf8());
592  SAL_WARN_IF(!pTarget, "vcl", "missing FormattedField element of spinbutton/adjustment");
593  SAL_WARN_IF(!pAdjustment, "vcl", "missing Adjustment element of spinbutton/adjustment");
594  if (pTarget && pAdjustment)
595  mungeAdjustment(*pTarget, *pAdjustment);
596  }
597 
598  //Set ScrollBar adjustments when everything has been imported
599  for (auto const& elem : m_pParserState->m_aScrollAdjustmentMaps)
600  {
601  ScrollBar *pTarget = get<ScrollBar>(elem.m_sID);
602  const Adjustment *pAdjustment = get_adjustment_by_name(elem.m_sValue.toUtf8());
603  SAL_WARN_IF(!pTarget || !pAdjustment, "vcl", "missing elements of scrollbar/adjustment");
604  if (pTarget && pAdjustment)
605  mungeAdjustment(*pTarget, *pAdjustment);
606  }
607 
608  //Set Scale(Slider) adjustments
609  for (auto const& elem : m_pParserState->m_aSliderAdjustmentMaps)
610  {
611  Slider* pTarget = dynamic_cast<Slider*>(get(elem.m_sID));
612  const Adjustment* pAdjustment = get_adjustment_by_name(elem.m_sValue.toUtf8());
613  SAL_WARN_IF(!pTarget || !pAdjustment, "vcl", "missing elements of scale(slider)/adjustment");
614  if (pTarget && pAdjustment)
615  {
616  mungeAdjustment(*pTarget, *pAdjustment);
617  }
618  }
619 
620  //Set size-groups when all widgets have been imported
621  for (auto const& sizeGroup : m_pParserState->m_aSizeGroups)
622  {
623  std::shared_ptr<VclSizeGroup> xGroup(std::make_shared<VclSizeGroup>());
624 
625  for (auto const& elem : sizeGroup.m_aProperties)
626  {
627  const OString &rKey = elem.first;
628  const OUString &rValue = elem.second;
629  xGroup->set_property(rKey, rValue);
630  }
631 
632  for (auto const& elem : sizeGroup.m_aWidgets)
633  {
634  vcl::Window* pWindow = get(elem.getStr());
635  pWindow->add_to_size_group(xGroup);
636  }
637  }
638 
639  //Set button images when everything has been imported
640  std::set<OUString> aImagesToBeRemoved;
641  for (auto const& elem : m_pParserState->m_aButtonImageWidgetMaps)
642  {
643  PushButton *pTargetButton = nullptr;
644  RadioButton *pTargetRadio = nullptr;
645  Button *pTarget = nullptr;
646 
647  if (!elem.m_bRadio)
648  {
649  pTargetButton = get<PushButton>(elem.m_sID);
650  pTarget = pTargetButton;
651  }
652  else
653  {
654  pTargetRadio = get<RadioButton>(elem.m_sID);
655  pTarget = pTargetRadio;
656  }
657 
658  FixedImage *pImage = get<FixedImage>(elem.m_sValue.toUtf8());
659  SAL_WARN_IF(!pTarget || !pImage,
660  "vcl", "missing elements of button/image/stock");
661  if (!pTarget || !pImage)
662  continue;
663  aImagesToBeRemoved.insert(elem.m_sValue);
664 
665  if (!elem.m_bRadio)
666  {
667  const Image& rImage = pImage->GetImage();
668  SymbolType eSymbol = mapStockToSymbol(rImage.GetStock());
669  if (eSymbol != SymbolType::IMAGE && eSymbol != SymbolType::DONTKNOW)
670  {
671  pTargetButton->SetSymbol(eSymbol);
672  //fdo#76457 keep symbol images small e.g. tools->customize->menu
673  //but images the right size. Really the PushButton::CalcMinimumSize
674  //and PushButton::ImplDrawPushButton are the better place to handle
675  //this, but its such a train-wreck
676  pTargetButton->SetStyle(pTargetButton->GetStyle() | WB_SMALLSTYLE);
677  }
678  else
679  {
680  pTargetButton->SetModeImage(rImage);
681  if (pImage->GetStyle() & WB_SMALLSTYLE)
682  {
683  Size aSz(rImage.GetSizePixel());
684  aSz.AdjustWidth(6);
685  aSz.AdjustHeight(6);
686  if (pTargetButton->get_width_request() == -1)
687  pTargetButton->set_width_request(aSz.Width());
688  if (pTargetButton->get_height_request() == -1)
689  pTargetButton->set_height_request(aSz.Height());
690  }
691  }
692  }
693  else
694  pTargetRadio->SetModeRadioImage(pImage->GetImage());
695 
696  auto aFind = m_pParserState->m_aImageSizeMap.find(elem.m_sValue.toUtf8());
697  if (aFind != m_pParserState->m_aImageSizeMap.end())
698  {
699  switch (aFind->second)
700  {
701  case 1:
702  pTarget->SetSmallSymbol();
703  break;
704  case 2:
705  assert(pImage->GetStyle() & WB_SMALLSTYLE);
706  pTarget->SetStyle(pTarget->GetStyle() | WB_SMALLSTYLE);
707  break;
708  case 3:
709  pTarget->SetStyle(pTarget->GetStyle() | WB_SMALLSTYLE);
710  // large toolbar, make bigger than normal (4)
711  pTarget->set_width_request(pTarget->GetOptimalSize().Width() * 1.5);
712  pTarget->set_height_request(pTarget->GetOptimalSize().Height() * 1.5);
713  break;
714  case 4:
715  break;
716  default:
717  SAL_WARN("vcl.builder", "unsupported image size " << aFind->second);
718  break;
719  }
720  m_pParserState->m_aImageSizeMap.erase(aFind);
721  }
722  }
723 
724  //There may be duplicate use of an Image, so we used a set to collect and
725  //now we can remove them from the tree after their final munge
726  for (auto const& elem : aImagesToBeRemoved)
727  {
728  delete_by_name(elem.toUtf8());
729  }
730 
731  //Set button menus when everything has been imported
732  for (auto const& elem : m_pParserState->m_aButtonMenuMaps)
733  {
734  MenuButton *pTarget = get<MenuButton>(elem.m_sID);
735  PopupMenu *pMenu = get_menu(elem.m_sValue.toUtf8());
736  SAL_WARN_IF(!pTarget || !pMenu,
737  "vcl", "missing elements of button/menu");
738  if (!pTarget || !pMenu)
739  continue;
740  pTarget->SetPopupMenu(pMenu);
741  }
742 
743  //Remove ScrollWindow parent widgets whose children in vcl implement scrolling
744  //internally.
745  for (auto const& elem : m_pParserState->m_aRedundantParentWidgets)
746  {
747  delete_by_window(elem.first);
748  }
749 
750  //fdo#67378 merge the label into the disclosure button
751  for (auto const& elem : m_pParserState->m_aExpanderWidgets)
752  {
753  vcl::Window *pChild = elem->get_child();
755  if (pLabel && pLabel != pChild && pLabel->GetType() == WindowType::FIXEDTEXT)
756  {
757  FixedText *pLabelWidget = static_cast<FixedText*>(pLabel);
758  elem->set_label(pLabelWidget->GetText());
759  if (pLabelWidget->IsControlFont())
760  elem->get_label_widget()->SetControlFont(pLabelWidget->GetControlFont());
761  delete_by_window(pLabel);
762  }
763  }
764 
765  // create message dialog message area now
766  for (auto const& elem : m_pParserState->m_aMessageDialogs)
767  elem->create_message_area();
768 
769  //drop maps, etc. that we don't need again
770  m_pParserState.reset();
771 
772  SAL_WARN_IF(!m_sID.isEmpty() && (!m_bToplevelParentFound && !get_by_name(m_sID)), "vcl.builder",
773  "Requested top level widget \"" << m_sID << "\" not found in " << sUIFile);
774 
775 #if defined SAL_LOG_WARN
776  if (m_bToplevelParentFound && m_pParent->IsDialog())
777  {
778  int nButtons = 0;
779  bool bHasDefButton = false;
780  for (auto const& child : m_aChildren)
781  {
782  if (isButtonType(child.m_pWindow->GetType()))
783  {
784  ++nButtons;
785  if (child.m_pWindow->GetStyle() & WB_DEFBUTTON)
786  {
787  bHasDefButton = true;
788  break;
789  }
790  }
791  }
792  SAL_WARN_IF(nButtons && !bHasDefButton, "vcl.builder", "No default button defined in " << sUIFile);
793  }
794 #endif
795 
796  const bool bHideHelp = comphelper::LibreOfficeKit::isActive() &&
797  officecfg::Office::Common::Help::HelpRootURL::get().isEmpty();
798  if (bHideHelp)
799  {
800  if (vcl::Window *pHelpButton = get("help"))
801  pHelpButton->Hide();
802  }
803 }
804 
806 {
807  disposeBuilder();
808 }
809 
811 {
812  for (std::vector<WinAndId>::reverse_iterator aI = m_aChildren.rbegin(),
813  aEnd = m_aChildren.rend(); aI != aEnd; ++aI)
814  {
815  aI->m_pWindow.disposeAndClear();
816  }
817  m_aChildren.clear();
818 
819  for (std::vector<MenuAndId>::reverse_iterator aI = m_aMenus.rbegin(),
820  aEnd = m_aMenus.rend(); aI != aEnd; ++aI)
821  {
822  aI->m_pMenu.disposeAndClear();
823  }
824  m_aMenus.clear();
825  m_pParent.clear();
826 }
827 
828 namespace
829 {
830  bool extractHasFrame(VclBuilder::stringmap& rMap)
831  {
832  bool bHasFrame = true;
833  VclBuilder::stringmap::iterator aFind = rMap.find("has-frame");
834  if (aFind != rMap.end())
835  {
836  bHasFrame = toBool(aFind->second);
837  rMap.erase(aFind);
838  }
839  return bHasFrame;
840  }
841 
842  bool extractDrawValue(VclBuilder::stringmap& rMap)
843  {
844  bool bDrawValue = true;
845  VclBuilder::stringmap::iterator aFind = rMap.find("draw-value");
846  if (aFind != rMap.end())
847  {
848  bDrawValue = toBool(aFind->second);
849  rMap.erase(aFind);
850  }
851  return bDrawValue;
852  }
853 
854  OUString extractPopupMenu(VclBuilder::stringmap& rMap)
855  {
856  OUString sRet;
857  VclBuilder::stringmap::iterator aFind = rMap.find("popup");
858  if (aFind != rMap.end())
859  {
860  sRet = aFind->second;
861  rMap.erase(aFind);
862  }
863  return sRet;
864  }
865 
866  OUString extractWidgetName(VclBuilder::stringmap& rMap)
867  {
868  OUString sRet;
869  VclBuilder::stringmap::iterator aFind = rMap.find("name");
870  if (aFind != rMap.end())
871  {
872  sRet = aFind->second;
873  rMap.erase(aFind);
874  }
875  return sRet;
876  }
877 
878  OUString extractValuePos(VclBuilder::stringmap& rMap)
879  {
880  OUString sRet("top");
881  VclBuilder::stringmap::iterator aFind = rMap.find("value-pos");
882  if (aFind != rMap.end())
883  {
884  sRet = aFind->second;
885  rMap.erase(aFind);
886  }
887  return sRet;
888  }
889 
890  OUString extractTypeHint(VclBuilder::stringmap &rMap)
891  {
892  OUString sRet("normal");
893  VclBuilder::stringmap::iterator aFind = rMap.find("type-hint");
894  if (aFind != rMap.end())
895  {
896  sRet = aFind->second;
897  rMap.erase(aFind);
898  }
899  return sRet;
900  }
901 
902  bool extractResizable(VclBuilder::stringmap &rMap)
903  {
904  bool bResizable = true;
905  VclBuilder::stringmap::iterator aFind = rMap.find("resizable");
906  if (aFind != rMap.end())
907  {
908  bResizable = toBool(aFind->second);
909  rMap.erase(aFind);
910  }
911  return bResizable;
912  }
913 
914 #if HAVE_FEATURE_DESKTOP
915  bool extractModal(VclBuilder::stringmap &rMap)
916  {
917  bool bModal = false;
918  VclBuilder::stringmap::iterator aFind = rMap.find("modal");
919  if (aFind != rMap.end())
920  {
921  bModal = toBool(aFind->second);
922  rMap.erase(aFind);
923  }
924  return bModal;
925  }
926 #endif
927 
928  bool extractDecorated(VclBuilder::stringmap &rMap)
929  {
930  bool bDecorated = true;
931  VclBuilder::stringmap::iterator aFind = rMap.find("decorated");
932  if (aFind != rMap.end())
933  {
934  bDecorated = toBool(aFind->second);
935  rMap.erase(aFind);
936  }
937  return bDecorated;
938  }
939 
940  bool extractCloseable(VclBuilder::stringmap &rMap)
941  {
942  bool bCloseable = true;
943  VclBuilder::stringmap::iterator aFind = rMap.find("deletable");
944  if (aFind != rMap.end())
945  {
946  bCloseable = toBool(aFind->second);
947  rMap.erase(aFind);
948  }
949  return bCloseable;
950  }
951 
952  bool extractEntry(VclBuilder::stringmap &rMap)
953  {
954  bool bHasEntry = false;
955  VclBuilder::stringmap::iterator aFind = rMap.find("has-entry");
956  if (aFind != rMap.end())
957  {
958  bHasEntry = toBool(aFind->second);
959  rMap.erase(aFind);
960  }
961  return bHasEntry;
962  }
963 
964  bool extractOrientation(VclBuilder::stringmap &rMap)
965  {
966  bool bVertical = false;
967  VclBuilder::stringmap::iterator aFind = rMap.find("orientation");
968  if (aFind != rMap.end())
969  {
970  bVertical = aFind->second.equalsIgnoreAsciiCase("vertical");
971  rMap.erase(aFind);
972  }
973  return bVertical;
974  }
975 
976  bool extractVerticalTabPos(VclBuilder::stringmap &rMap)
977  {
978  bool bVertical = false;
979  VclBuilder::stringmap::iterator aFind = rMap.find("tab-pos");
980  if (aFind != rMap.end())
981  {
982  bVertical = aFind->second.equalsIgnoreAsciiCase("left") ||
983  aFind->second.equalsIgnoreAsciiCase("right");
984  rMap.erase(aFind);
985  }
986  return bVertical;
987  }
988 
989  bool extractInconsistent(VclBuilder::stringmap &rMap)
990  {
991  bool bInconsistent = false;
992  VclBuilder::stringmap::iterator aFind = rMap.find("inconsistent");
993  if (aFind != rMap.end())
994  {
995  bInconsistent = toBool(aFind->second);
996  rMap.erase(aFind);
997  }
998  return bInconsistent;
999  }
1000 
1001  OUString extractIconName(VclBuilder::stringmap &rMap)
1002  {
1003  OUString sIconName;
1004  // allow pixbuf, but prefer icon-name
1005  {
1006  VclBuilder::stringmap::iterator aFind = rMap.find(OString("pixbuf"));
1007  if (aFind != rMap.end())
1008  {
1009  sIconName = aFind->second;
1010  rMap.erase(aFind);
1011  }
1012  }
1013  {
1014  VclBuilder::stringmap::iterator aFind = rMap.find(OString("icon-name"));
1015  if (aFind != rMap.end())
1016  {
1017  sIconName = aFind->second;
1018  rMap.erase(aFind);
1019  }
1020  }
1021  if (sIconName == "missing-image")
1022  return OUString();
1023  OUString sReplace = mapStockToImageResource(sIconName);
1024  return !sReplace.isEmpty() ? sReplace : sIconName;
1025  }
1026 
1027  WinBits extractRelief(VclBuilder::stringmap &rMap)
1028  {
1029  WinBits nBits = WB_3DLOOK;
1030  VclBuilder::stringmap::iterator aFind = rMap.find(OString("relief"));
1031  if (aFind != rMap.end())
1032  {
1033  if (aFind->second == "half")
1034  nBits = WB_FLATBUTTON | WB_BEVELBUTTON;
1035  else if (aFind->second == "none")
1036  nBits = WB_FLATBUTTON;
1037  rMap.erase(aFind);
1038  }
1039  return nBits;
1040  }
1041 
1042  OUString extractLabel(VclBuilder::stringmap &rMap)
1043  {
1044  OUString sType;
1045  VclBuilder::stringmap::iterator aFind = rMap.find(OString("label"));
1046  if (aFind != rMap.end())
1047  {
1048  sType = aFind->second;
1049  rMap.erase(aFind);
1050  }
1051  return sType;
1052  }
1053 
1054  OUString extractActionName(VclBuilder::stringmap &rMap)
1055  {
1056  OUString sActionName;
1057  VclBuilder::stringmap::iterator aFind = rMap.find(OString("action-name"));
1058  if (aFind != rMap.end())
1059  {
1060  sActionName = aFind->second;
1061  rMap.erase(aFind);
1062  }
1063  return sActionName;
1064  }
1065 
1066  bool extractVisible(VclBuilder::stringmap &rMap)
1067  {
1068  bool bRet = false;
1069  VclBuilder::stringmap::iterator aFind = rMap.find(OString("visible"));
1070  if (aFind != rMap.end())
1071  {
1072  bRet = toBool(aFind->second);
1073  rMap.erase(aFind);
1074  }
1075  return bRet;
1076  }
1077 
1078  Size extractSizeRequest(VclBuilder::stringmap &rMap)
1079  {
1080  OUString sWidthRequest("0");
1081  OUString sHeightRequest("0");
1082  VclBuilder::stringmap::iterator aFind = rMap.find(OString("width-request"));
1083  if (aFind != rMap.end())
1084  {
1085  sWidthRequest = aFind->second;
1086  rMap.erase(aFind);
1087  }
1088  aFind = rMap.find("height-request");
1089  if (aFind != rMap.end())
1090  {
1091  sHeightRequest = aFind->second;
1092  rMap.erase(aFind);
1093  }
1094  return Size(sWidthRequest.toInt32(), sHeightRequest.toInt32());
1095  }
1096 
1097  OUString extractTooltipText(VclBuilder::stringmap &rMap)
1098  {
1099  OUString sTooltipText;
1100  VclBuilder::stringmap::iterator aFind = rMap.find(OString("tooltip-text"));
1101  if (aFind == rMap.end())
1102  aFind = rMap.find(OString("tooltip-markup"));
1103  if (aFind != rMap.end())
1104  {
1105  sTooltipText = aFind->second;
1106  rMap.erase(aFind);
1107  }
1108  return sTooltipText;
1109  }
1110 
1111  float extractAlignment(VclBuilder::stringmap &rMap)
1112  {
1113  float f = 0.0;
1114  VclBuilder::stringmap::iterator aFind = rMap.find(OString("alignment"));
1115  if (aFind != rMap.end())
1116  {
1117  f = aFind->second.toFloat();
1118  rMap.erase(aFind);
1119  }
1120  return f;
1121  }
1122 
1123  OUString extractTitle(VclBuilder::stringmap &rMap)
1124  {
1125  OUString sTitle;
1126  VclBuilder::stringmap::iterator aFind = rMap.find(OString("title"));
1127  if (aFind != rMap.end())
1128  {
1129  sTitle = aFind->second;
1130  rMap.erase(aFind);
1131  }
1132  return sTitle;
1133  }
1134 
1135  bool extractHeadersVisible(VclBuilder::stringmap &rMap)
1136  {
1137  bool bHeadersVisible = true;
1138  VclBuilder::stringmap::iterator aFind = rMap.find(OString("headers-visible"));
1139  if (aFind != rMap.end())
1140  {
1141  bHeadersVisible = toBool(aFind->second);
1142  rMap.erase(aFind);
1143  }
1144  return bHeadersVisible;
1145  }
1146 
1147  bool extractSortIndicator(VclBuilder::stringmap &rMap)
1148  {
1149  bool bSortIndicator = false;
1150  VclBuilder::stringmap::iterator aFind = rMap.find(OString("sort-indicator"));
1151  if (aFind != rMap.end())
1152  {
1153  bSortIndicator = toBool(aFind->second);
1154  rMap.erase(aFind);
1155  }
1156  return bSortIndicator;
1157  }
1158 
1159  bool extractClickable(VclBuilder::stringmap &rMap)
1160  {
1161  bool bClickable = false;
1162  VclBuilder::stringmap::iterator aFind = rMap.find(OString("clickable"));
1163  if (aFind != rMap.end())
1164  {
1165  bClickable = toBool(aFind->second);
1166  rMap.erase(aFind);
1167  }
1168  return bClickable;
1169  }
1170 
1171  void setupFromActionName(Button *pButton, VclBuilder::stringmap &rMap, const css::uno::Reference<css::frame::XFrame>& rFrame)
1172  {
1173  if (!rFrame.is())
1174  return;
1175 
1176  OUString aCommand(extractActionName(rMap));
1177  if (aCommand.isEmpty())
1178  return;
1179 
1180  OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(rFrame));
1181  auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aCommand, aModuleName);
1183  if (!aLabel.isEmpty())
1184  pButton->SetText(aLabel);
1185 
1186  OUString aTooltip(vcl::CommandInfoProvider::GetTooltipForCommand(aCommand, aProperties, rFrame));
1187  if (!aTooltip.isEmpty())
1188  pButton->SetQuickHelpText(aTooltip);
1189 
1190  Image aImage(vcl::CommandInfoProvider::GetImageForCommand(aCommand, rFrame));
1191  pButton->SetModeImage(aImage);
1192 
1193  pButton->SetCommandHandler(aCommand);
1194  }
1195 
1196  VclPtr<Button> extractStockAndBuildPushButton(vcl::Window *pParent, VclBuilder::stringmap &rMap, bool bToggle)
1197  {
1199  if (bToggle)
1200  nBits |= WB_TOGGLE;
1201 
1202  nBits |= extractRelief(rMap);
1203 
1204  VclPtr<Button> xWindow = VclPtr<PushButton>::Create(pParent, nBits);
1205  return xWindow;
1206  }
1207 
1208  VclPtr<MenuButton> extractStockAndBuildMenuButton(vcl::Window *pParent, VclBuilder::stringmap &rMap)
1209  {
1211 
1212  nBits |= extractRelief(rMap);
1213 
1214  VclPtr<MenuButton> xWindow = VclPtr<MenuButton>::Create(pParent, nBits);
1215  return xWindow;
1216  }
1217 
1218  VclPtr<MenuButton> extractStockAndBuildMenuToggleButton(vcl::Window *pParent, VclBuilder::stringmap &rMap)
1219  {
1221 
1222  nBits |= extractRelief(rMap);
1223 
1224  VclPtr<MenuButton> xWindow = VclPtr<MenuToggleButton>::Create(pParent, nBits);
1225  return xWindow;
1226  }
1227 
1228  WinBits extractDeferredBits(VclBuilder::stringmap &rMap)
1229  {
1230  WinBits nBits = WB_3DLOOK|WB_HIDE;
1231  if (extractResizable(rMap))
1232  nBits |= WB_SIZEABLE;
1233  if (extractCloseable(rMap))
1234  nBits |= WB_CLOSEABLE;
1235  if (!extractDecorated(rMap))
1236  nBits |= WB_OWNERDRAWDECORATION;
1237  OUString sType(extractTypeHint(rMap));
1238  if (sType == "utility")
1240  else if (sType == "popup-menu")
1242  else if (sType == "dock")
1243  nBits |= WB_DOCKABLE | WB_MOVEABLE;
1244  else
1245  nBits |= WB_MOVEABLE;
1246  return nBits;
1247  }
1248 }
1249 
1250 void VclBuilder::extractGroup(const OString &id, stringmap &rMap)
1251 {
1252  VclBuilder::stringmap::iterator aFind = rMap.find(OString("group"));
1253  if (aFind != rMap.end())
1254  {
1255  OUString sID = aFind->second;
1256  sal_Int32 nDelim = sID.indexOf(':');
1257  if (nDelim != -1)
1258  sID = sID.copy(0, nDelim);
1259  m_pParserState->m_aGroupMaps.emplace_back(id, sID.toUtf8());
1260  rMap.erase(aFind);
1261  }
1262 }
1263 
1264 void VclBuilder::connectNumericFormatterAdjustment(const OString &id, const OUString &rAdjustment)
1265 {
1266  if (!rAdjustment.isEmpty())
1267  m_pParserState->m_aNumericFormatterAdjustmentMaps.emplace_back(id, rAdjustment);
1268 }
1269 
1270 void VclBuilder::connectFormattedFormatterAdjustment(const OString &id, const OUString &rAdjustment)
1271 {
1272  if (!rAdjustment.isEmpty())
1273  m_pParserState->m_aFormattedFormatterAdjustmentMaps.emplace_back(id, rAdjustment);
1274 }
1275 
1276 bool VclBuilder::extractAdjustmentToMap(const OString& id, VclBuilder::stringmap& rMap, std::vector<WidgetAdjustmentMap>& rAdjustmentMap)
1277 {
1278  VclBuilder::stringmap::iterator aFind = rMap.find(OString("adjustment"));
1279  if (aFind != rMap.end())
1280  {
1281  rAdjustmentMap.emplace_back(id, aFind->second);
1282  rMap.erase(aFind);
1283  return true;
1284  }
1285  return false;
1286 }
1287 
1288 namespace
1289 {
1290  sal_Int32 extractActive(VclBuilder::stringmap &rMap)
1291  {
1292  sal_Int32 nActiveId = 0;
1293  VclBuilder::stringmap::iterator aFind = rMap.find(OString("active"));
1294  if (aFind != rMap.end())
1295  {
1296  nActiveId = aFind->second.toInt32();
1297  rMap.erase(aFind);
1298  }
1299  return nActiveId;
1300  }
1301 
1302  bool extractSelectable(VclBuilder::stringmap &rMap)
1303  {
1304  bool bSelectable = false;
1305  VclBuilder::stringmap::iterator aFind = rMap.find(OString("selectable"));
1306  if (aFind != rMap.end())
1307  {
1308  bSelectable = toBool(aFind->second);
1309  rMap.erase(aFind);
1310  }
1311  return bSelectable;
1312  }
1313 
1314  OUString extractAdjustment(VclBuilder::stringmap &rMap)
1315  {
1316  OUString sAdjustment;
1317  VclBuilder::stringmap::iterator aFind = rMap.find(OString("adjustment"));
1318  if (aFind != rMap.end())
1319  {
1320  sAdjustment= aFind->second;
1321  rMap.erase(aFind);
1322  return sAdjustment;
1323  }
1324  return sAdjustment;
1325  }
1326 
1327  bool extractDrawIndicator(VclBuilder::stringmap &rMap)
1328  {
1329  bool bDrawIndicator = false;
1330  VclBuilder::stringmap::iterator aFind = rMap.find(OString("draw-indicator"));
1331  if (aFind != rMap.end())
1332  {
1333  bDrawIndicator = toBool(aFind->second);
1334  rMap.erase(aFind);
1335  }
1336  return bDrawIndicator;
1337  }
1338 }
1339 
1340 void VclBuilder::extractModel(const OString &id, stringmap &rMap)
1341 {
1342  VclBuilder::stringmap::iterator aFind = rMap.find(OString("model"));
1343  if (aFind != rMap.end())
1344  {
1345  m_pParserState->m_aModelMaps.emplace_back(id, aFind->second,
1346  extractActive(rMap));
1347  rMap.erase(aFind);
1348  }
1349 }
1350 
1351 void VclBuilder::extractBuffer(const OString &id, stringmap &rMap)
1352 {
1353  VclBuilder::stringmap::iterator aFind = rMap.find(OString("buffer"));
1354  if (aFind != rMap.end())
1355  {
1356  m_pParserState->m_aTextBufferMaps.emplace_back(id, aFind->second);
1357  rMap.erase(aFind);
1358  }
1359 }
1360 
1362 {
1363  int nSize = 4;
1364  auto aFind = rMap.find(OString("icon-size"));
1365  if (aFind != rMap.end())
1366  nSize = aFind->second.toInt32();
1367  return nSize;
1368 }
1369 
1370 void VclBuilder::extractButtonImage(const OString &id, stringmap &rMap, bool bRadio)
1371 {
1372  VclBuilder::stringmap::iterator aFind = rMap.find(OString("image"));
1373  if (aFind != rMap.end())
1374  {
1375  m_pParserState->m_aButtonImageWidgetMaps.emplace_back(id, aFind->second, bRadio);
1376  rMap.erase(aFind);
1377  }
1378 }
1379 
1380 void VclBuilder::extractMnemonicWidget(const OString &rLabelID, stringmap &rMap)
1381 {
1382  VclBuilder::stringmap::iterator aFind = rMap.find(OString("mnemonic-widget"));
1383  if (aFind != rMap.end())
1384  {
1385  OUString sID = aFind->second;
1386  sal_Int32 nDelim = sID.indexOf(':');
1387  if (nDelim != -1)
1388  sID = sID.copy(0, nDelim);
1389  m_pParserState->m_aMnemonicWidgetMaps.emplace_back(rLabelID, sID);
1390  rMap.erase(aFind);
1391  }
1392 }
1393 
1395 {
1396  //For Widgets that manage their own scrolling, if one appears as a child of
1397  //a scrolling window shoehorn that scrolling settings to this widget and
1398  //return the real parent to use
1399  if (pParent && pParent->GetType() == WindowType::SCROLLWINDOW)
1400  {
1401  WinBits nScrollBits = pParent->GetStyle();
1403  rWinStyle |= nScrollBits;
1404  if (static_cast<VclScrolledWindow*>(pParent)->HasVisibleBorder())
1405  rWinStyle |= WB_BORDER;
1406  pParent = pParent->GetParent();
1407  }
1408 
1409  return pParent;
1410 }
1411 
1413 {
1414  //remove the redundant scrolling parent
1415  sal_Int32 nWidthReq = pScrollParent->get_width_request();
1416  rMap[OString("width-request")] = OUString::number(nWidthReq);
1417  sal_Int32 nHeightReq = pScrollParent->get_height_request();
1418  rMap[OString("height-request")] = OUString::number(nHeightReq);
1419 
1420  m_pParserState->m_aRedundantParentWidgets[pScrollParent] = pWindow;
1421 }
1422 
1423 #ifndef DISABLE_DYNLOADING
1424 
1425 extern "C" { static void thisModule() {} }
1426 
1427 namespace {
1428 
1429 // Don't unload the module on destruction
1430 class NoAutoUnloadModule : public osl::Module
1431 {
1432 public:
1433  ~NoAutoUnloadModule() { release(); }
1434 };
1435 
1436 }
1437 
1438 typedef std::map<OUString, std::shared_ptr<NoAutoUnloadModule>> ModuleMap;
1439 static ModuleMap g_aModuleMap;
1440 
1441 #if ENABLE_MERGELIBS
1442 static std::shared_ptr<NoAutoUnloadModule> g_pMergedLib = std::make_shared<NoAutoUnloadModule>();
1443 #endif
1444 
1445 #ifndef SAL_DLLPREFIX
1446 # define SAL_DLLPREFIX ""
1447 #endif
1448 
1449 #endif
1450 
1451 namespace vcl {
1452 
1454 {
1455 #ifndef DISABLE_DYNLOADING
1456 
1457 #if ENABLE_MERGELIBS
1458  g_pMergedLib->loadRelative(&thisModule, SVLIBRARY("merged"));
1459 #else
1460 // find -name '*ui*' | xargs grep 'class=".*lo-' |
1461 // sed 's/.*class="//' | sed 's/-.*$//' | sort | uniq
1462  static const char *aWidgetLibs[] = {
1463  "sfxlo", "svtlo"
1464  };
1465  for (const auto & lib : aWidgetLibs)
1466  {
1467  std::unique_ptr<NoAutoUnloadModule> pModule(new NoAutoUnloadModule);
1468  OUString sModule = SAL_DLLPREFIX + OUString::createFromAscii(lib) + SAL_DLLEXTENSION;
1469  if (pModule->loadRelative(&thisModule, sModule))
1470  g_aModuleMap.insert(std::make_pair(sModule, std::move(pModule)));
1471  }
1472 #endif // ENABLE_MERGELIBS
1473 #endif // DISABLE_DYNLOADING
1474 }
1475 
1476 }
1477 
1478 #if defined DISABLE_DYNLOADING && !HAVE_FEATURE_DESKTOP
1479 extern "C" VclBuilder::customMakeWidget lo_get_custom_widget_func(const char* name);
1480 #endif
1481 
1482 namespace
1483 {
1484 // Takes a string like "sfxlo-NotebookbarToolBox"
1485 VclBuilder::customMakeWidget GetCustomMakeWidget(const OString& rName)
1486 {
1487  const OString name = rName == "sfxlo-SidebarToolBox" ? "sfxlo-NotebookbarToolBox" : rName;
1488  VclBuilder::customMakeWidget pFunction = nullptr;
1489  if (sal_Int32 nDelim = name.indexOf('-'); nDelim != -1)
1490  {
1491  const OString aFunction(OString::Concat("make") + name.subView(nDelim + 1));
1492  const OUString sFunction(OStringToOUString(aFunction, RTL_TEXTENCODING_UTF8));
1493 
1494 #ifndef DISABLE_DYNLOADING
1495  const OUString sModule = SAL_DLLPREFIX
1496  + OStringToOUString(name.subView(0, nDelim), RTL_TEXTENCODING_UTF8)
1497  + SAL_DLLEXTENSION;
1498  ModuleMap::iterator aI = g_aModuleMap.find(sModule);
1499  if (aI == g_aModuleMap.end())
1500  {
1501  std::shared_ptr<NoAutoUnloadModule> pModule;
1502 #if ENABLE_MERGELIBS
1503  if (!g_pMergedLib->is())
1504  g_pMergedLib->loadRelative(&thisModule, SVLIBRARY("merged"));
1505  if ((pFunction = reinterpret_cast<VclBuilder::customMakeWidget>(
1506  g_pMergedLib->getFunctionSymbol(sFunction))))
1507  pModule = g_pMergedLib;
1508 #endif
1509  if (!pFunction)
1510  {
1511  pModule = std::make_shared<NoAutoUnloadModule>();
1512  bool ok = pModule->loadRelative(&thisModule, sModule);
1513  if (!ok)
1514  {
1515 #ifdef LINUX
1516  // in the case of preloading, we don't have eg. the
1517  // libcuilo.so, but still need to dlsym the symbols -
1518  // which are already in-process
1520  {
1521  pFunction = reinterpret_cast<VclBuilder::customMakeWidget>(dlsym(RTLD_DEFAULT, aFunction.getStr()));
1522  ok = !!pFunction;
1523  assert(ok && "couldn't even directly dlsym the sFunction (available via preload)");
1524  }
1525 #endif
1526  assert(ok && "bad module name in .ui");
1527  }
1528  else
1529  {
1530  pFunction = reinterpret_cast<VclBuilder::customMakeWidget>(
1531  pModule->getFunctionSymbol(sFunction));
1532  }
1533  }
1534  g_aModuleMap.insert(std::make_pair(sModule, pModule));
1535  }
1536  else
1537  pFunction = reinterpret_cast<VclBuilder::customMakeWidget>(
1538  aI->second->getFunctionSymbol(sFunction));
1539 #elif !HAVE_FEATURE_DESKTOP
1540  pFunction = lo_get_custom_widget_func(sFunction.toUtf8().getStr());
1541  SAL_WARN_IF(!pFunction, "vcl.builder", "Could not find " << sFunction);
1542  assert(pFunction);
1543 #else
1544  pFunction = reinterpret_cast<VclBuilder::customMakeWidget>(
1545  osl_getFunctionSymbol((oslModule)RTLD_DEFAULT, sFunction.pData));
1546 #endif
1547  }
1548  return pFunction;
1549 }
1550 }
1551 
1552 VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &name, const OString &id,
1553  stringmap &rMap)
1554 {
1555  bool bIsPlaceHolder = name.isEmpty();
1556  bool bVertical = false;
1557 
1558  if (pParent && (pParent->GetType() == WindowType::TABCONTROL ||
1559  pParent->GetType() == WindowType::VERTICALTABCONTROL))
1560  {
1561  bool bTopLevel(name == "GtkDialog" || name == "GtkMessageDialog" ||
1562  name == "GtkWindow" || name == "GtkPopover" || name == "GtkAssistant");
1563  if (!bTopLevel)
1564  {
1565  if (pParent->GetType() == WindowType::TABCONTROL)
1566  {
1567  //We have to add a page
1568  //make default pageid == position
1569  TabControl *pTabControl = static_cast<TabControl*>(pParent);
1570  sal_uInt16 nNewPageCount = pTabControl->GetPageCount()+1;
1571  sal_uInt16 nNewPageId = nNewPageCount;
1572  pTabControl->InsertPage(nNewPageId, OUString());
1573  pTabControl->SetCurPageId(nNewPageId);
1574  SAL_WARN_IF(bIsPlaceHolder, "vcl.builder", "we should have no placeholders for tabpages");
1575  if (!bIsPlaceHolder)
1576  {
1577  VclPtrInstance<TabPage> pPage(pTabControl);
1578  pPage->Show();
1579 
1580  //Make up a name for it
1581  OString sTabPageId = get_by_window(pParent) +
1582  "-page" +
1583  OString::number(nNewPageCount);
1584  m_aChildren.emplace_back(sTabPageId, pPage, false);
1585  pPage->SetHelpId(m_sHelpRoot + sTabPageId);
1586 
1587  pParent = pPage;
1588 
1589  pTabControl->SetTabPage(nNewPageId, pPage);
1590  }
1591  }
1592  else
1593  {
1594  VerticalTabControl *pTabControl = static_cast<VerticalTabControl*>(pParent);
1595  SAL_WARN_IF(bIsPlaceHolder, "vcl.builder", "we should have no placeholders for tabpages");
1596  if (!bIsPlaceHolder)
1597  pParent = pTabControl->GetPageParent();
1598  }
1599  }
1600  }
1601 
1602  if (bIsPlaceHolder || name == "GtkTreeSelection")
1603  return nullptr;
1604 
1605  ToolBox *pToolBox = (pParent && pParent->GetType() == WindowType::TOOLBOX) ? static_cast<ToolBox*>(pParent) : nullptr;
1606 
1607  extractButtonImage(id, rMap, name == "GtkRadioButton");
1608 
1609  VclPtr<vcl::Window> xWindow;
1610  if (name == "GtkDialog" || name == "GtkAssistant")
1611  {
1612  // WB_ALLOWMENUBAR because we don't know in advance if we will encounter
1613  // a menubar, and menubars need a BorderWindow in the toplevel, and
1614  // such border windows need to be in created during the dialog ctor
1616  if (extractResizable(rMap))
1617  nBits |= WB_SIZEABLE;
1618  if (extractCloseable(rMap))
1619  nBits |= WB_CLOSEABLE;
1621  if (name == "GtkAssistant")
1622  xWindow = VclPtr<vcl::RoadmapWizard>::Create(pParent, nBits, eInit);
1623  else
1624  xWindow = VclPtr<Dialog>::Create(pParent, nBits, eInit);
1625 #if HAVE_FEATURE_DESKTOP
1626  if (!extractModal(rMap))
1627  xWindow->SetType(WindowType::MODELESSDIALOG);
1628 #endif
1629  }
1630  else if (name == "GtkMessageDialog")
1631  {
1633  if (extractResizable(rMap))
1634  nBits |= WB_SIZEABLE;
1635  VclPtr<MessageDialog> xDialog(VclPtr<MessageDialog>::Create(pParent, nBits));
1636  m_pParserState->m_aMessageDialogs.push_back(xDialog);
1637  xWindow = xDialog;
1638 #if defined _WIN32
1639  xWindow->set_border_width(3);
1640 #else
1641  xWindow->set_border_width(12);
1642 #endif
1643  }
1644  else if (name == "GtkBox" || name == "GtkStatusbar")
1645  {
1646  bVertical = extractOrientation(rMap);
1647  if (bVertical)
1648  xWindow = VclPtr<VclVBox>::Create(pParent);
1649  else
1650  xWindow = VclPtr<VclHBox>::Create(pParent);
1651  }
1652  else if (name == "GtkPaned")
1653  {
1654  bVertical = extractOrientation(rMap);
1655  if (bVertical)
1656  xWindow = VclPtr<VclVPaned>::Create(pParent);
1657  else
1658  xWindow = VclPtr<VclHPaned>::Create(pParent);
1659  }
1660  else if (name == "GtkHBox")
1661  xWindow = VclPtr<VclHBox>::Create(pParent);
1662  else if (name == "GtkVBox")
1663  xWindow = VclPtr<VclVBox>::Create(pParent);
1664  else if (name == "GtkButtonBox")
1665  {
1666  bVertical = extractOrientation(rMap);
1667  if (bVertical)
1668  xWindow = VclPtr<VclVButtonBox>::Create(pParent);
1669  else
1670  xWindow = VclPtr<VclHButtonBox>::Create(pParent);
1671  }
1672  else if (name == "GtkHButtonBox")
1673  xWindow = VclPtr<VclHButtonBox>::Create(pParent);
1674  else if (name == "GtkVButtonBox")
1675  xWindow = VclPtr<VclVButtonBox>::Create(pParent);
1676  else if (name == "GtkGrid")
1677  xWindow = VclPtr<VclGrid>::Create(pParent);
1678  else if (name == "GtkFrame")
1679  xWindow = VclPtr<VclFrame>::Create(pParent);
1680  else if (name == "GtkExpander")
1681  {
1682  VclPtrInstance<VclExpander> pExpander(pParent);
1683  m_pParserState->m_aExpanderWidgets.push_back(pExpander);
1684  xWindow = pExpander;
1685  }
1686  else if (name == "GtkButton" || (!m_bLegacy && name == "GtkToggleButton"))
1687  {
1688  VclPtr<Button> xButton;
1689  OUString sMenu = BuilderUtils::extractCustomProperty(rMap);
1690  if (sMenu.isEmpty())
1691  xButton = extractStockAndBuildPushButton(pParent, rMap, name == "GtkToggleButton");
1692  else
1693  {
1694  assert(m_bLegacy && "use GtkMenuButton");
1695  xButton = extractStockAndBuildMenuButton(pParent, rMap);
1696  m_pParserState->m_aButtonMenuMaps.emplace_back(id, sMenu);
1697  }
1698  xButton->SetImageAlign(ImageAlign::Left); //default to left
1699  setupFromActionName(xButton, rMap, m_xFrame);
1700  xWindow = xButton;
1701  }
1702  else if (name == "GtkMenuButton")
1703  {
1704  VclPtr<MenuButton> xButton;
1705 
1706  OUString sMenu = extractPopupMenu(rMap);
1707  if (!sMenu.isEmpty())
1708  m_pParserState->m_aButtonMenuMaps.emplace_back(id, sMenu);
1709 
1710  OUString sType = extractWidgetName(rMap);
1711  if (sType.isEmpty())
1712  {
1713  xButton = extractStockAndBuildMenuButton(pParent, rMap);
1714  xButton->SetAccessibleRole(css::accessibility::AccessibleRole::BUTTON_MENU);
1715  }
1716  else
1717  {
1718  xButton = extractStockAndBuildMenuToggleButton(pParent, rMap);
1719  }
1720 
1721  xButton->SetImageAlign(ImageAlign::Left); //default to left
1722 
1723  if (!extractDrawIndicator(rMap))
1725 
1726  setupFromActionName(xButton, rMap, m_xFrame);
1727  xWindow = xButton;
1728  }
1729  else if (name == "GtkToggleButton" && m_bLegacy)
1730  {
1731  VclPtr<Button> xButton;
1732  OUString sMenu = BuilderUtils::extractCustomProperty(rMap);
1733  assert(sMenu.getLength() && "not implemented yet");
1734  xButton = extractStockAndBuildMenuToggleButton(pParent, rMap);
1735  m_pParserState->m_aButtonMenuMaps.emplace_back(id, sMenu);
1736  xButton->SetImageAlign(ImageAlign::Left); //default to left
1737  setupFromActionName(xButton, rMap, m_xFrame);
1738  xWindow = xButton;
1739  }
1740  else if (name == "GtkRadioButton")
1741  {
1742  extractGroup(id, rMap);
1744  VclPtr<RadioButton> xButton = VclPtr<RadioButton>::Create(pParent, true, nBits);
1745  xButton->SetImageAlign(ImageAlign::Left); //default to left
1746  xWindow = xButton;
1747  }
1748  else if (name == "GtkCheckButton")
1749  {
1751  bool bIsTriState = extractInconsistent(rMap);
1752  VclPtr<CheckBox> xCheckBox = VclPtr<CheckBox>::Create(pParent, nBits);
1753  if (bIsTriState)
1754  {
1755  xCheckBox->EnableTriState(true);
1756  xCheckBox->SetState(TRISTATE_INDET);
1757  }
1758  xCheckBox->SetImageAlign(ImageAlign::Left); //default to left
1759 
1760  xWindow = xCheckBox;
1761  }
1762  else if (name == "GtkSpinButton")
1763  {
1764  OUString sAdjustment = extractAdjustment(rMap);
1765 
1767  if (extractHasFrame(rMap))
1768  nBits |= WB_BORDER;
1769 
1770  connectFormattedFormatterAdjustment(id, sAdjustment);
1771  VclPtrInstance<FormattedField> xField(pParent, nBits);
1772  xField->GetFormatter().SetMinValue(0);
1773  xWindow = xField;
1774  }
1775  else if (name == "GtkLinkButton")
1777  else if (name == "GtkComboBox" || name == "GtkComboBoxText")
1778  {
1779  extractModel(id, rMap);
1780 
1782 
1783  bool bDropdown = BuilderUtils::extractDropdown(rMap);
1784 
1785  if (bDropdown)
1786  nBits |= WB_DROPDOWN;
1787 
1788  if (extractEntry(rMap))
1789  {
1790  VclPtrInstance<ComboBox> xComboBox(pParent, nBits);
1791  xComboBox->EnableAutoSize(true);
1792  xWindow = xComboBox;
1793  }
1794  else
1795  {
1796  VclPtrInstance<ListBox> xListBox(pParent, nBits|WB_SIMPLEMODE);
1797  xListBox->EnableAutoSize(true);
1798  xWindow = xListBox;
1799  }
1800  }
1801  else if (name == "VclOptionalBox" || name == "sfxlo-OptionalBox")
1802  {
1803  // tdf#135495 fallback sfxlo-OptionalBox to VclOptionalBox as a stopgap
1804  xWindow = VclPtr<OptionalBox>::Create(pParent);
1805  }
1806  else if (name == "svtlo-ManagedMenuButton")
1807  {
1808  // like tdf#135495 keep the name svtlo-ManagedMenuButton even though it's a misnomer
1809  // and is not dlsymed from the svt library
1811  OUString sMenu = BuilderUtils::extractCustomProperty(rMap);
1812  if (!sMenu.isEmpty())
1813  m_pParserState->m_aButtonMenuMaps.emplace_back(id, sMenu);
1814  setupFromActionName(static_cast<Button*>(xWindow.get()), rMap, m_xFrame);
1815  }
1816  else if (name == "sfxlo-PriorityMergedHBox")
1817  {
1818  // like tdf#135495 above, keep the sfxlo-PriorityMergedHBox even though its not in sfx anymore
1819  xWindow = VclPtr<PriorityMergedHBox>::Create(pParent);
1820  }
1821  else if (name == "sfxlo-PriorityHBox")
1822  {
1823  // like tdf#135495 above, keep the sfxlo-PriorityMergedHBox even though its not in sfx anymore
1824  xWindow = VclPtr<PriorityHBox>::Create(pParent);
1825  }
1826  else if (name == "sfxlo-DropdownBox")
1827  {
1828  // like tdf#135495 above, keep the sfxlo-PriorityMergedHBox even though its not in sfx anymore
1829  xWindow = VclPtr<DropdownBox>::Create(pParent);
1830  }
1831  else if (name == "sfxlo-ContextVBox")
1832  {
1833  // like tdf#135495 above, keep the sfxlo-PriorityMergedHBox even though its not in sfx anymore
1834  xWindow = VclPtr<ContextVBox>::Create(pParent);
1835  }
1836  else if (name == "GtkIconView")
1837  {
1838  assert(rMap.find(OString("model")) != rMap.end() && "GtkIconView must have a model");
1839 
1840  //window we want to apply the packing props for this GtkIconView to
1841  VclPtr<vcl::Window> xWindowForPackingProps;
1842  extractModel(id, rMap);
1844  //IconView manages its own scrolling,
1845  vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle);
1846 
1847  VclPtr<IconView> xBox = VclPtr<IconView>::Create(pRealParent, nWinStyle);
1848  xWindowForPackingProps = xBox;
1849 
1850  xWindow = xBox;
1851  xBox->SetNoAutoCurEntry(true);
1852  xBox->SetQuickSearch(true);
1853 
1854  if (pRealParent != pParent)
1855  cleanupWidgetOwnScrolling(pParent, xWindowForPackingProps, rMap);
1856  }
1857  else if (name == "GtkTreeView")
1858  {
1859  if (!m_bLegacy)
1860  {
1861  assert(rMap.find(OString("model")) != rMap.end() && "GtkTreeView must have a model");
1862  }
1863 
1864  //window we want to apply the packing props for this GtkTreeView to
1865  VclPtr<vcl::Window> xWindowForPackingProps;
1866  //To-Do
1867  //a) make SvHeaderTabListBox/SvTabListBox the default target for GtkTreeView
1868  //b) remove the non-drop down mode of ListBox and convert
1869  // everything over to SvHeaderTabListBox/SvTabListBox
1870  //c) remove the users of makeSvTabListBox and makeSvTreeListBox
1871  extractModel(id, rMap);
1873  if (m_bLegacy)
1874  {
1876  if (!sBorder.isEmpty())
1877  nWinStyle |= WB_BORDER;
1878  }
1879  else
1880  {
1881  nWinStyle |= WB_HASBUTTONS | WB_HASBUTTONSATROOT;
1882  }
1883  //ListBox/SvHeaderTabListBox manages its own scrolling,
1884  vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle);
1885  if (m_bLegacy)
1886  {
1887  xWindow = VclPtr<ListBox>::Create(pRealParent, nWinStyle | WB_SIMPLEMODE);
1888  xWindowForPackingProps = xWindow;
1889  }
1890  else
1891  {
1892  VclPtr<SvTabListBox> xBox;
1893  bool bHeadersVisible = extractHeadersVisible(rMap);
1894  if (bHeadersVisible)
1895  {
1896  VclPtr<VclVBox> xContainer = VclPtr<VclVBox>::Create(pRealParent);
1897  OString containerid(id + "-container");
1898  xContainer->SetHelpId(m_sHelpRoot + containerid);
1899  m_aChildren.emplace_back(containerid, xContainer, true);
1900 
1902  xHeader->set_width_request(0); // let the headerbar width not affect the size request
1903  OString headerid(id + "-header");
1904  xHeader->SetHelpId(m_sHelpRoot + headerid);
1905  m_aChildren.emplace_back(headerid, xHeader, true);
1906 
1907  VclPtr<LclHeaderTabListBox> xHeaderBox = VclPtr<LclHeaderTabListBox>::Create(xContainer, nWinStyle);
1908  xHeaderBox->InitHeaderBar(xHeader);
1909  xContainer->set_expand(true);
1910  xHeader->Show();
1911  xContainer->Show();
1912  xBox = xHeaderBox;
1913  xWindowForPackingProps = xContainer;
1914  }
1915  else
1916  {
1917  xBox = VclPtr<LclTabListBox>::Create(pRealParent, nWinStyle);
1918  xWindowForPackingProps = xBox;
1919  }
1920  xWindow = xBox;
1921  xBox->SetNoAutoCurEntry(true);
1922  xBox->SetQuickSearch(true);
1923  xBox->SetSpaceBetweenEntries(3);
1924  xBox->SetEntryHeight(16);
1925  xBox->SetHighlightRange(); // select over the whole width
1926  }
1927  if (pRealParent != pParent)
1928  cleanupWidgetOwnScrolling(pParent, xWindowForPackingProps, rMap);
1929  }
1930  else if (name == "GtkTreeViewColumn")
1931  {
1932  if (!m_bLegacy)
1933  {
1934  SvHeaderTabListBox* pTreeView = dynamic_cast<SvHeaderTabListBox*>(pParent);
1935  if (HeaderBar* pHeaderBar = pTreeView ? pTreeView->GetHeaderBar() : nullptr)
1936  {
1938  if (extractClickable(rMap))
1940  if (extractSortIndicator(rMap))
1942  float fAlign = extractAlignment(rMap);
1943  if (fAlign == 0.0)
1944  nBits |= HeaderBarItemBits::LEFT;
1945  else if (fAlign == 1.0)
1946  nBits |= HeaderBarItemBits::RIGHT;
1947  else if (fAlign == 0.5)
1948  nBits |= HeaderBarItemBits::CENTER;
1949  auto nItemId = pHeaderBar->GetItemCount() + 1;
1950  OUString sTitle(extractTitle(rMap));
1951  pHeaderBar->InsertItem(nItemId, sTitle, 100, nBits);
1952  }
1953  }
1954  }
1955  else if (name == "GtkLabel")
1956  {
1957  WinBits nWinStyle = WB_CENTER|WB_VCENTER|WB_3DLOOK;
1958  extractMnemonicWidget(id, rMap);
1959  if (extractSelectable(rMap))
1960  xWindow = VclPtr<SelectableFixedText>::Create(pParent, nWinStyle);
1961  else
1962  xWindow = VclPtr<FixedText>::Create(pParent, nWinStyle);
1963  }
1964  else if (name == "GtkImage")
1965  {
1967  OUString sIconName = extractIconName(rMap);
1968  if (!sIconName.isEmpty())
1969  xFixedImage->SetImage(FixedImage::loadThemeImage(sIconName));
1970  m_pParserState->m_aImageSizeMap[id] = getImageSize(rMap);
1971  xWindow = xFixedImage;
1972  //such parentless GtkImages are temps used to set icons on buttons
1973  //default them to hidden to stop e.g. insert->index entry flicking temp
1974  //full screen windows
1975  if (!pParent)
1976  {
1977  rMap["visible"] = "false";
1978  }
1979  }
1980  else if (name == "GtkSeparator")
1981  {
1982  bVertical = extractOrientation(rMap);
1983  xWindow = VclPtr<FixedLine>::Create(pParent, bVertical ? WB_VERT : WB_HORZ);
1984  }
1985  else if (name == "GtkScrollbar")
1986  {
1987  extractAdjustmentToMap(id, rMap, m_pParserState->m_aScrollAdjustmentMaps);
1988  bVertical = extractOrientation(rMap);
1989  xWindow = VclPtr<ScrollBar>::Create(pParent, bVertical ? WB_VERT : WB_HORZ);
1990  }
1991  else if (name == "GtkProgressBar")
1992  {
1993  extractAdjustmentToMap(id, rMap, m_pParserState->m_aScrollAdjustmentMaps);
1994  bVertical = extractOrientation(rMap);
1995  xWindow = VclPtr<ProgressBar>::Create(pParent, bVertical ? WB_VERT : WB_HORZ);
1996  }
1997  else if (name == "GtkScrolledWindow")
1998  {
1999  xWindow = VclPtr<VclScrolledWindow>::Create(pParent);
2000  }
2001  else if (name == "GtkViewport")
2002  {
2003  xWindow = VclPtr<VclViewport>::Create(pParent);
2004  }
2005  else if (name == "GtkEventBox")
2006  {
2007  xWindow = VclPtr<VclEventBox>::Create(pParent);
2008  }
2009  else if (name == "GtkEntry")
2010  {
2011  WinBits nWinStyle = WB_LEFT|WB_VCENTER|WB_3DLOOK;
2012  if (extractHasFrame(rMap))
2013  nWinStyle |= WB_BORDER;
2014  xWindow = VclPtr<Edit>::Create(pParent, nWinStyle);
2016  }
2017  else if (name == "GtkNotebook")
2018  {
2019  if (!extractVerticalTabPos(rMap))
2021  else
2022  xWindow = VclPtr<VerticalTabControl>::Create(pParent);
2023  }
2024  else if (name == "GtkDrawingArea")
2025  {
2026  xWindow = VclPtr<VclDrawingArea>::Create(pParent, WB_TABSTOP);
2027  }
2028  else if (name == "GtkTextView")
2029  {
2030  extractBuffer(id, rMap);
2031 
2032  WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT;
2033  //VclMultiLineEdit manages its own scrolling,
2034  vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle);
2035  xWindow = VclPtr<VclMultiLineEdit>::Create(pRealParent, nWinStyle);
2036  if (pRealParent != pParent)
2037  cleanupWidgetOwnScrolling(pParent, xWindow, rMap);
2038  }
2039  else if (name == "GtkSpinner")
2040  {
2041  xWindow = VclPtr<Throbber>::Create(pParent, WB_3DLOOK);
2042  }
2043  else if (name == "GtkScale")
2044  {
2045  extractAdjustmentToMap(id, rMap, m_pParserState->m_aSliderAdjustmentMaps);
2046  bool bDrawValue = extractDrawValue(rMap);
2047  if (bDrawValue)
2048  {
2049  OUString sValuePos = extractValuePos(rMap);
2050  (void)sValuePos;
2051  }
2052  bVertical = extractOrientation(rMap);
2053 
2054  WinBits nWinStyle = bVertical ? WB_VERT : WB_HORZ;
2055 
2056  xWindow = VclPtr<Slider>::Create(pParent, nWinStyle);
2057  }
2058  else if (name == "GtkToolbar")
2059  {
2060  xWindow = VclPtr<ToolBox>::Create(pParent, WB_3DLOOK | WB_TABSTOP);
2061  }
2062  else if(name == "NotebookBarAddonsToolMergePoint")
2063  {
2064  customMakeWidget pFunction = GetCustomMakeWidget("sfxlo-NotebookbarToolBox");
2065  if(pFunction != nullptr)
2067  return nullptr;
2068  }
2069  else if (name == "GtkToolButton" || name == "GtkMenuToolButton" ||
2070  name == "GtkToggleToolButton" || name == "GtkRadioToolButton" || name == "GtkToolItem")
2071  {
2072  if (pToolBox)
2073  {
2074  OUString aCommand(extractActionName(rMap));
2075 
2076  ToolBoxItemId nItemId(0);
2078  if (name == "GtkMenuToolButton")
2079  nBits |= ToolBoxItemBits::DROPDOWN;
2080  else if (name == "GtkToggleToolButton")
2082  else if (name == "GtkRadioToolButton")
2084 
2085  if (!aCommand.isEmpty() && m_xFrame.is())
2086  {
2087  pToolBox->InsertItem(aCommand, m_xFrame, nBits, extractSizeRequest(rMap));
2088  nItemId = pToolBox->GetItemId(aCommand);
2089  }
2090  else
2091  {
2092  nItemId = ToolBoxItemId(pToolBox->GetItemCount() + 1);
2093  //TODO: ImplToolItems::size_type -> sal_uInt16!
2094  pToolBox->InsertItem(nItemId, extractLabel(rMap), nBits);
2095  if (aCommand.isEmpty() && !m_bLegacy)
2096  aCommand = OUString::fromUtf8(id);
2097  pToolBox->SetItemCommand(nItemId, aCommand);
2098  }
2099 
2100  pToolBox->SetHelpId(nItemId, m_sHelpRoot + id);
2101  OUString sTooltip(extractTooltipText(rMap));
2102  if (!sTooltip.isEmpty())
2103  pToolBox->SetQuickHelpText(nItemId, sTooltip);
2104 
2105  OUString sIconName(extractIconName(rMap));
2106  if (!sIconName.isEmpty())
2107  pToolBox->SetItemImage(nItemId, FixedImage::loadThemeImage(sIconName));
2108 
2109  if (!extractVisible(rMap))
2110  pToolBox->HideItem(nItemId);
2111 
2112  m_pParserState->m_nLastToolbarId = nItemId;
2113 
2114  return nullptr; // no widget to be created
2115  }
2116  }
2117  else if (name == "GtkSeparatorToolItem")
2118  {
2119  if (pToolBox)
2120  {
2121  pToolBox->InsertSeparator();
2122  return nullptr; // no widget to be created
2123  }
2124  }
2125  else if (name == "GtkWindow")
2126  {
2127  WinBits nBits = extractDeferredBits(rMap);
2128  if (nBits & WB_DOCKABLE)
2129  xWindow = VclPtr<DockingWindow>::Create(pParent, nBits|WB_MOVEABLE);
2130  else
2131  xWindow = VclPtr<FloatingWindow>::Create(pParent, nBits|WB_MOVEABLE);
2132  }
2133  else if (name == "GtkPopover")
2134  {
2135  WinBits nBits = extractDeferredBits(rMap);
2136  xWindow = VclPtr<DockingWindow>::Create(pParent, nBits|WB_DOCKABLE|WB_MOVEABLE);
2137  }
2138  else if (name == "GtkCalendar")
2139  {
2140  WinBits nBits = extractDeferredBits(rMap);
2141  xWindow = VclPtr<Calendar>::Create(pParent, nBits);
2142  }
2143  else
2144  {
2145  if (customMakeWidget pFunction = GetCustomMakeWidget(name))
2146  {
2147  pFunction(xWindow, pParent, rMap);
2148  if (xWindow->GetType() == WindowType::PUSHBUTTON)
2149  setupFromActionName(static_cast<Button*>(xWindow.get()), rMap, m_xFrame);
2150  else if (xWindow->GetType() == WindowType::MENUBUTTON)
2151  {
2152  OUString sMenu = BuilderUtils::extractCustomProperty(rMap);
2153  if (!sMenu.isEmpty())
2154  m_pParserState->m_aButtonMenuMaps.emplace_back(id, sMenu);
2155  setupFromActionName(static_cast<Button*>(xWindow.get()), rMap, m_xFrame);
2156  }
2157  }
2158  }
2159 
2160  SAL_INFO_IF(!xWindow, "vcl.builder", "probably need to implement " << name << " or add a make" << name << " function");
2161  if (xWindow)
2162  {
2163  // child windows of disabled windows are made disabled by vcl by default, we don't want that
2164  WindowImpl *pWindowImpl = xWindow->ImplGetWindowImpl();
2165  pWindowImpl->mbDisabled = false;
2166 
2167  xWindow->SetHelpId(m_sHelpRoot + id);
2168  SAL_INFO("vcl.builder", "for name '" << name << "' and id '" << id <<
2169  "', created " << xWindow.get() << " child of " <<
2170  pParent << "(" << xWindow->ImplGetWindowImpl()->mpParent.get() << "/" <<
2171  xWindow->ImplGetWindowImpl()->mpRealParent.get() << "/" <<
2172  xWindow->ImplGetWindowImpl()->mpBorderWindow.get() << ") with helpid " <<
2173  xWindow->GetHelpId());
2174  m_aChildren.emplace_back(id, xWindow, bVertical);
2175 
2176  // if the parent was a toolbox set it as an itemwindow for the latest itemid
2177  if (pToolBox)
2178  {
2179  Size aSize(xWindow->GetSizePixel());
2180  aSize.setHeight(xWindow->get_preferred_size().Height());
2181  xWindow->SetSizePixel(aSize);
2182  pToolBox->SetItemWindow(m_pParserState->m_nLastToolbarId, xWindow);
2183  pToolBox->SetItemExpand(m_pParserState->m_nLastToolbarId, true);
2184  }
2185  }
2186  return xWindow;
2187 }
2188 
2189 namespace
2190 {
2191  //return true for window types which exist in vcl but are not themselves
2192  //represented in the .ui format, i.e. only their children exist.
2193  bool isConsideredGtkPseudo(vcl::Window const *pWindow)
2194  {
2195  return pWindow->GetType() == WindowType::TABPAGE;
2196  }
2197 }
2198 
2199 //Any properties from .ui load we couldn't set because of potential virtual methods
2200 //during ctor are applied here
2202 {
2204  return;
2205  stringmap aDeferredProperties;
2206  aDeferredProperties.swap(m_aDeferredProperties);
2208  BuilderUtils::set_properties(m_pParent, aDeferredProperties);
2209 }
2210 
2211 namespace BuilderUtils
2212 {
2213  void set_properties(vcl::Window *pWindow, const VclBuilder::stringmap &rProps)
2214  {
2215  for (auto const& prop : rProps)
2216  {
2217  const OString &rKey = prop.first;
2218  const OUString &rValue = prop.second;
2219  pWindow->set_property(rKey, rValue);
2220  }
2221  }
2222 
2223  OUString convertMnemonicMarkup(const OUString &rIn)
2224  {
2225  OUStringBuffer aRet(rIn);
2226  for (sal_Int32 nI = 0; nI < aRet.getLength(); ++nI)
2227  {
2228  if (aRet[nI] == '_' && nI+1 < aRet.getLength())
2229  {
2230  if (aRet[nI+1] != '_')
2231  aRet[nI] = MNEMONIC_CHAR;
2232  else
2233  aRet.remove(nI, 1);
2234  ++nI;
2235  }
2236  }
2237  return aRet.makeStringAndClear();
2238  }
2239 
2241  {
2242  OUString sCustomProperty;
2243  VclBuilder::stringmap::iterator aFind = rMap.find(OString("customproperty"));
2244  if (aFind != rMap.end())
2245  {
2246  sCustomProperty = aFind->second;
2247  rMap.erase(aFind);
2248  }
2249  return sCustomProperty;
2250  }
2251 
2253  {
2254  OString sWidthChars("width-chars");
2255  VclBuilder::stringmap::iterator aFind = rMap.find(sWidthChars);
2256  if (aFind == rMap.end())
2257  rMap[sWidthChars] = "25";
2258  }
2259 
2261  {
2262  bool bDropdown = true;
2263  VclBuilder::stringmap::iterator aFind = rMap.find(OString("dropdown"));
2264  if (aFind != rMap.end())
2265  {
2266  bDropdown = toBool(aFind->second);
2267  rMap.erase(aFind);
2268  }
2269  return bDropdown;
2270  }
2271 
2272  void reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition)
2273  {
2274  WindowImpl *pWindowImpl = rWindow.ImplGetWindowImpl();
2275  if (pWindowImpl->mpParent != pWindowImpl->mpRealParent)
2276  {
2277  assert(pWindowImpl->mpBorderWindow == pWindowImpl->mpParent);
2278  assert(pWindowImpl->mpBorderWindow->ImplGetWindowImpl()->mpParent == pWindowImpl->mpRealParent);
2279  reorderWithinParent(*pWindowImpl->mpBorderWindow, nNewPosition);
2280  return;
2281  }
2282  rWindow.reorderWithinParent(nNewPosition);
2283  }
2284 
2285  void reorderWithinParent(std::vector<vcl::Window*>& rChilds, bool bIsButtonBox)
2286  {
2287  for (size_t i = 0; i < rChilds.size(); ++i)
2288  {
2289  reorderWithinParent(*rChilds[i], i);
2290 
2291  if (!bIsButtonBox)
2292  continue;
2293 
2294  //The first member of the group for legacy code needs WB_GROUP set and the
2295  //others not
2296  WinBits nBits = rChilds[i]->GetStyle();
2297  nBits &= ~WB_GROUP;
2298  if (i == 0)
2299  nBits |= WB_GROUP;
2300  rChilds[i]->SetStyle(nBits);
2301  }
2302  }
2303 
2304  sal_Int16 getRoleFromName(const OString& roleName)
2305  {
2306  using namespace com::sun::star::accessibility;
2307 
2308  static const std::unordered_map<OString, sal_Int16> aAtkRoleToAccessibleRole = {
2309  /* This is in atkobject.h's AtkRole order */
2310  { "invalid", AccessibleRole::UNKNOWN },
2311  { "accelerator label", AccessibleRole::UNKNOWN },
2312  { "alert", AccessibleRole::ALERT },
2313  { "animation", AccessibleRole::UNKNOWN },
2314  { "arrow", AccessibleRole::UNKNOWN },
2315  { "calendar", AccessibleRole::UNKNOWN },
2316  { "canvas", AccessibleRole::CANVAS },
2317  { "check box", AccessibleRole::CHECK_BOX },
2318  { "check menu item", AccessibleRole::CHECK_MENU_ITEM },
2319  { "color chooser", AccessibleRole::COLOR_CHOOSER },
2320  { "column header", AccessibleRole::COLUMN_HEADER },
2321  { "combo box", AccessibleRole::COMBO_BOX },
2322  { "date editor", AccessibleRole::DATE_EDITOR },
2323  { "desktop icon", AccessibleRole::DESKTOP_ICON },
2324  { "desktop frame", AccessibleRole::DESKTOP_PANE }, // ?
2325  { "dial", AccessibleRole::UNKNOWN },
2326  { "dialog", AccessibleRole::DIALOG },
2327  { "directory pane", AccessibleRole::DIRECTORY_PANE },
2328  { "drawing area", AccessibleRole::UNKNOWN },
2329  { "file chooser", AccessibleRole::FILE_CHOOSER },
2330  { "filler", AccessibleRole::FILLER },
2331  { "font chooser", AccessibleRole::FONT_CHOOSER },
2332  { "frame", AccessibleRole::FRAME },
2333  { "glass pane", AccessibleRole::GLASS_PANE },
2334  { "html container", AccessibleRole::UNKNOWN },
2335  { "icon", AccessibleRole::ICON },
2336  { "image", AccessibleRole::GRAPHIC },
2337  { "internal frame", AccessibleRole::INTERNAL_FRAME },
2338  { "label", AccessibleRole::LABEL },
2339  { "layered pane", AccessibleRole::LAYERED_PANE },
2340  { "list", AccessibleRole::LIST },
2341  { "list item", AccessibleRole::LIST_ITEM },
2342  { "menu", AccessibleRole::MENU },
2343  { "menu bar", AccessibleRole::MENU_BAR },
2344  { "menu item", AccessibleRole::MENU_ITEM },
2345  { "option pane", AccessibleRole::OPTION_PANE },
2346  { "page tab", AccessibleRole::PAGE_TAB },
2347  { "page tab list", AccessibleRole::PAGE_TAB_LIST },
2348  { "panel", AccessibleRole::PANEL }, // or SHAPE or TEXT_FRAME ?
2349  { "password text", AccessibleRole::PASSWORD_TEXT },
2350  { "popup menu", AccessibleRole::POPUP_MENU },
2351  { "progress bar", AccessibleRole::PROGRESS_BAR },
2352  { "push button", AccessibleRole::PUSH_BUTTON }, // or BUTTON_DROPDOWN or BUTTON_MENU
2353  { "radio button", AccessibleRole::RADIO_BUTTON },
2354  { "radio menu item", AccessibleRole::RADIO_MENU_ITEM },
2355  { "root pane", AccessibleRole::ROOT_PANE },
2356  { "row header", AccessibleRole::ROW_HEADER },
2357  { "scroll bar", AccessibleRole::SCROLL_BAR },
2358  { "scroll pane", AccessibleRole::SCROLL_PANE },
2359  { "separator", AccessibleRole::SEPARATOR },
2360  { "slider", AccessibleRole::SLIDER },
2361  { "split pane", AccessibleRole::SPLIT_PANE },
2362  { "spin button", AccessibleRole::SPIN_BOX }, // ?
2363  { "statusbar", AccessibleRole::STATUS_BAR },
2364  { "table", AccessibleRole::TABLE },
2365  { "table cell", AccessibleRole::TABLE_CELL },
2366  { "table column header", AccessibleRole::COLUMN_HEADER }, // approximate
2367  { "table row header", AccessibleRole::ROW_HEADER }, // approximate
2368  { "tear off menu item", AccessibleRole::UNKNOWN },
2369  { "terminal", AccessibleRole::UNKNOWN },
2370  { "text", AccessibleRole::TEXT },
2371  { "toggle button", AccessibleRole::TOGGLE_BUTTON },
2372  { "tool bar", AccessibleRole::TOOL_BAR },
2373  { "tool tip", AccessibleRole::TOOL_TIP },
2374  { "tree", AccessibleRole::TREE },
2375  { "tree table", AccessibleRole::TREE_TABLE },
2376  { "unknown", AccessibleRole::UNKNOWN },
2377  { "viewport", AccessibleRole::VIEW_PORT },
2378  { "window", AccessibleRole::WINDOW },
2379  { "header", AccessibleRole::HEADER },
2380  { "footer", AccessibleRole::FOOTER },
2381  { "paragraph", AccessibleRole::PARAGRAPH },
2382  { "ruler", AccessibleRole::RULER },
2383  { "application", AccessibleRole::UNKNOWN },
2384  { "autocomplete", AccessibleRole::UNKNOWN },
2385  { "edit bar", AccessibleRole::EDIT_BAR },
2386  { "embedded", AccessibleRole::EMBEDDED_OBJECT },
2387  { "entry", AccessibleRole::UNKNOWN },
2388  { "chart", AccessibleRole::CHART },
2389  { "caption", AccessibleRole::CAPTION },
2390  { "document frame", AccessibleRole::DOCUMENT },
2391  { "heading", AccessibleRole::HEADING },
2392  { "page", AccessibleRole::PAGE },
2393  { "section", AccessibleRole::SECTION },
2394  { "redundant object", AccessibleRole::UNKNOWN },
2395  { "form", AccessibleRole::FORM },
2396  { "link", AccessibleRole::HYPER_LINK },
2397  { "input method window", AccessibleRole::UNKNOWN },
2398  { "table row", AccessibleRole::UNKNOWN },
2399  { "tree item", AccessibleRole::TREE_ITEM },
2400  { "document spreadsheet", AccessibleRole::DOCUMENT_SPREADSHEET },
2401  { "document presentation", AccessibleRole::DOCUMENT_PRESENTATION },
2402  { "document text", AccessibleRole::DOCUMENT_TEXT },
2403  { "document web", AccessibleRole::DOCUMENT }, // approximate
2404  { "document email", AccessibleRole::DOCUMENT }, // approximate
2405  { "comment", AccessibleRole::COMMENT }, // or NOTE or END_NOTE or FOOTNOTE or SCROLL_PANE
2406  { "list box", AccessibleRole::UNKNOWN },
2407  { "grouping", AccessibleRole::GROUP_BOX },
2408  { "image map", AccessibleRole::IMAGE_MAP },
2409  { "notification", AccessibleRole::UNKNOWN },
2410  { "info bar", AccessibleRole::UNKNOWN },
2411  { "level bar", AccessibleRole::UNKNOWN },
2412  { "title bar", AccessibleRole::UNKNOWN },
2413  { "block quote", AccessibleRole::UNKNOWN },
2414  { "audio", AccessibleRole::UNKNOWN },
2415  { "video", AccessibleRole::UNKNOWN },
2416  { "definition", AccessibleRole::UNKNOWN },
2417  { "article", AccessibleRole::UNKNOWN },
2418  { "landmark", AccessibleRole::UNKNOWN },
2419  { "log", AccessibleRole::UNKNOWN },
2420  { "marquee", AccessibleRole::UNKNOWN },
2421  { "math", AccessibleRole::UNKNOWN },
2422  { "rating", AccessibleRole::UNKNOWN },
2423  { "timer", AccessibleRole::UNKNOWN },
2424  { "description list", AccessibleRole::UNKNOWN },
2425  { "description term", AccessibleRole::UNKNOWN },
2426  { "description value", AccessibleRole::UNKNOWN },
2427  { "static", AccessibleRole::STATIC },
2428  { "math fraction", AccessibleRole::UNKNOWN },
2429  { "math root", AccessibleRole::UNKNOWN },
2430  { "subscript", AccessibleRole::UNKNOWN },
2431  { "superscript", AccessibleRole::UNKNOWN },
2432  { "footnote", AccessibleRole::FOOTNOTE },
2433  };
2434 
2435  auto it = aAtkRoleToAccessibleRole.find(roleName);
2436  if (it == aAtkRoleToAccessibleRole.end())
2437  return AccessibleRole::UNKNOWN;
2438  return it->second;
2439  }
2440 }
2441 
2443  const OString &rID, stringmap &rProps, stringmap &rPango, stringmap &rAtk)
2444 {
2445  VclPtr<vcl::Window> pCurrentChild;
2446 
2447  if (m_pParent && !isConsideredGtkPseudo(m_pParent) && !m_sID.isEmpty() && rID == m_sID)
2448  {
2449  pCurrentChild = m_pParent;
2450 
2451  //toplevels default to resizable and apparently you can't change them
2452  //afterwards, so we need to wait until now before we can truly
2453  //initialize the dialog.
2454  if (pParent && pParent->IsSystemWindow())
2455  {
2456  SystemWindow *pSysWin = static_cast<SystemWindow*>(pCurrentChild.get());
2457  pSysWin->doDeferredInit(extractDeferredBits(rProps));
2458  m_bToplevelHasDeferredInit = false;
2459  }
2460  else if (pParent && pParent->IsDockingWindow())
2461  {
2462  DockingWindow *pDockWin = static_cast<DockingWindow*>(pCurrentChild.get());
2463  pDockWin->doDeferredInit(extractDeferredBits(rProps));
2464  m_bToplevelHasDeferredInit = false;
2465  }
2466 
2467  if (pCurrentChild->GetHelpId().isEmpty())
2468  {
2469  pCurrentChild->SetHelpId(m_sHelpRoot + m_sID);
2470  SAL_INFO("vcl.builder", "for toplevel dialog " << this << " " <<
2471  rID << ", set helpid " << pCurrentChild->GetHelpId());
2472  }
2473  m_bToplevelParentFound = true;
2474  }
2475  else
2476  {
2477  //if we're being inserting under a toplevel dialog whose init is
2478  //deferred due to waiting to encounter it in this .ui, and it hasn't
2479  //been seen yet, then make unattached widgets parent-less toplevels
2480  if (pParent == m_pParent.get() && m_bToplevelHasDeferredInit)
2481  pParent = nullptr;
2482  pCurrentChild = makeObject(pParent, rClass, rID, rProps);
2483  }
2484 
2485  if (pCurrentChild)
2486  {
2487  pCurrentChild->set_id(OStringToOUString(rID, RTL_TEXTENCODING_UTF8));
2488  if (pCurrentChild == m_pParent.get() && m_bToplevelHasDeferredProperties)
2489  m_aDeferredProperties = rProps;
2490  else
2491  BuilderUtils::set_properties(pCurrentChild, rProps);
2492 
2493  for (auto const& elem : rPango)
2494  {
2495  const OString &rKey = elem.first;
2496  const OUString &rValue = elem.second;
2497  pCurrentChild->set_font_attribute(rKey, rValue);
2498  }
2499 
2500  m_pParserState->m_aAtkInfo[pCurrentChild] = rAtk;
2501  }
2502 
2503  rProps.clear();
2504  rPango.clear();
2505  rAtk.clear();
2506 
2507  if (!pCurrentChild)
2508  {
2509  bool bToolbarParent = (pParent && pParent->GetType() == WindowType::TOOLBOX);
2510  pCurrentChild = (m_aChildren.empty() || bToolbarParent) ? pParent : m_aChildren.back().m_pWindow.get();
2511  }
2512  return pCurrentChild;
2513 }
2514 
2516 {
2517  TabControl *pTabControl = pParent && pParent->GetType() == WindowType::TABCONTROL ?
2518  static_cast<TabControl*>(pParent) : nullptr;
2519 
2520  std::vector<OString> sIDs;
2521 
2522  int nLevel = 1;
2524  stringmap aAtkProperties;
2525  std::vector<vcl::EnumContext::Context> context;
2526 
2527  while(true)
2528  {
2529  xmlreader::Span name;
2530  int nsId;
2531 
2533  xmlreader::XmlReader::Text::NONE, &name, &nsId);
2534 
2536  {
2537  ++nLevel;
2538  if (name == "object")
2539  {
2540  while (reader.nextAttribute(&nsId, &name))
2541  {
2542  if (name == "id")
2543  {
2544  name = reader.getAttributeValue(false);
2545  OString sID(name.begin, name.length);
2546  sal_Int32 nDelim = sID.indexOf(':');
2547  if (nDelim != -1)
2548  {
2549  OString sPattern = sID.copy(nDelim+1);
2550  aProperties[OString("customproperty")] = OUString::fromUtf8(sPattern);
2551  sID = sID.copy(0, nDelim);
2552  }
2553  sIDs.push_back(sID);
2554  }
2555  }
2556  }
2557  else if (name == "style")
2558  {
2559  int nPriority = 0;
2560  context = handleStyle(reader, nPriority);
2561  --nLevel;
2562  }
2563  else if (name == "property")
2564  collectProperty(reader, aProperties);
2565  else if (pTabControl && name == "child")
2566  {
2567  // just to collect the atk properties (if any) for the label
2568  handleChild(nullptr, &aAtkProperties, reader);
2569  --nLevel;
2570  }
2571  }
2572 
2574  --nLevel;
2575 
2576  if (!nLevel)
2577  break;
2578 
2580  break;
2581  }
2582 
2583  if (!pParent)
2584  return;
2585 
2586  VerticalTabControl *pVerticalTabControl = pParent->GetType() == WindowType::VERTICALTABCONTROL ?
2587  static_cast<VerticalTabControl*>(pParent) : nullptr;
2588  assert(pTabControl || pVerticalTabControl);
2589  VclBuilder::stringmap::iterator aFind = aProperties.find(OString("label"));
2590  if (aFind != aProperties.end())
2591  {
2592  OUString sTooltip(extractTooltipText(aProperties));
2593  if (pTabControl)
2594  {
2595  sal_uInt16 nPageId = pTabControl->GetCurPageId();
2596  pTabControl->SetPageText(nPageId, aFind->second);
2597  pTabControl->SetPageName(nPageId, sIDs.back());
2598  pTabControl->SetHelpText(nPageId, sTooltip);
2599  if (!context.empty())
2600  {
2601  TabPage* pPage = pTabControl->GetTabPage(nPageId);
2602  pPage->SetContext(context);
2603  }
2604 
2605  for (auto const& prop : aAtkProperties)
2606  {
2607  const OString &rKey = prop.first;
2608  const OUString &rValue = prop.second;
2609 
2610  if (rKey == "AtkObject::accessible-name")
2611  pTabControl->SetAccessibleName(nPageId, rValue);
2612  else if (rKey == "AtkObject::accessible-description")
2613  pTabControl->SetAccessibleDescription(nPageId, rValue);
2614  else
2615  SAL_INFO("vcl.builder", "unhandled atk property: " << rKey);
2616  }
2617 
2618  }
2619  else
2620  {
2621  OUString sLabel(BuilderUtils::convertMnemonicMarkup(aFind->second));
2622  OUString sIconName(extractIconName(aProperties));
2623  pVerticalTabControl->InsertPage(sIDs.front(), sLabel, FixedImage::loadThemeImage(sIconName), sTooltip,
2624  pVerticalTabControl->GetPageParent()->GetWindow(GetWindowType::LastChild));
2625  }
2626  }
2627  else
2628  {
2629  if (pTabControl)
2630  pTabControl->RemovePage(pTabControl->GetCurPageId());
2631  }
2632 }
2633 
2634 //so that tabbing between controls goes in a visually sensible sequence
2635 //we sort these into a best-tab-order sequence
2637 {
2638  //sort child order within parent list by grid position
2639  sal_Int32 nTopA = pA->get_grid_top_attach();
2640  sal_Int32 nTopB = pB->get_grid_top_attach();
2641  if (nTopA < nTopB)
2642  return true;
2643  if (nTopA > nTopB)
2644  return false;
2645  sal_Int32 nLeftA = pA->get_grid_left_attach();
2646  sal_Int32 nLeftB = pB->get_grid_left_attach();
2647  if (nLeftA < nLeftB)
2648  return true;
2649  if (nLeftA > nLeftB)
2650  return false;
2651  //sort into two groups of pack start and pack end
2652  VclPackType ePackA = pA->get_pack_type();
2653  VclPackType ePackB = pB->get_pack_type();
2654  if (ePackA < ePackB)
2655  return true;
2656  if (ePackA > ePackB)
2657  return false;
2658  bool bVerticalContainer = m_pBuilder->get_window_packing_data(pA->GetParent()).m_bVerticalOrient;
2659  bool bPackA = pA->get_secondary();
2660  bool bPackB = pB->get_secondary();
2661  if (!bVerticalContainer)
2662  {
2663  //for horizontal boxes group secondaries before primaries
2664  if (bPackA > bPackB)
2665  return true;
2666  if (bPackA < bPackB)
2667  return false;
2668  }
2669  else
2670  {
2671  //for vertical boxes group secondaries after primaries
2672  if (bPackA < bPackB)
2673  return true;
2674  if (bPackA > bPackB)
2675  return false;
2676  }
2677  //honour relative box positions with pack group, (numerical order is reversed
2678  //for VclPackType::End, they are packed from the end back, but here we need
2679  //them in visual layout order so that tabbing works as expected)
2680  sal_Int32 nPackA = m_pBuilder->get_window_packing_data(pA).m_nPosition;
2681  sal_Int32 nPackB = m_pBuilder->get_window_packing_data(pB).m_nPosition;
2682  if (nPackA < nPackB)
2683  return ePackA == VclPackType::Start;
2684  if (nPackA > nPackB)
2685  return ePackA != VclPackType::Start;
2686  //sort labels of Frames before body
2687  if (pA->GetParent() == pB->GetParent())
2688  {
2689  const VclFrame *pFrameParent = dynamic_cast<const VclFrame*>(pA->GetParent());
2690  if (pFrameParent)
2691  {
2692  const vcl::Window *pLabel = pFrameParent->get_label_widget();
2693  int nFramePosA = (pA == pLabel) ? 0 : 1;
2694  int nFramePosB = (pB == pLabel) ? 0 : 1;
2695  return nFramePosA < nFramePosB;
2696  }
2697  }
2698  return false;
2699 }
2700 
2702 {
2703  vcl::Window *pCurrentChild = nullptr;
2704 
2705  xmlreader::Span name;
2706  int nsId;
2707  OString sType, sInternalChild;
2708 
2709  while (reader.nextAttribute(&nsId, &name))
2710  {
2711  if (name == "type")
2712  {
2713  name = reader.getAttributeValue(false);
2714  sType = OString(name.begin, name.length);
2715  }
2716  else if (name == "internal-child")
2717  {
2718  name = reader.getAttributeValue(false);
2719  sInternalChild = OString(name.begin, name.length);
2720  }
2721  }
2722 
2723  if (sType == "tab")
2724  {
2725  handleTabChild(pParent, reader);
2726  return;
2727  }
2728 
2729  int nLevel = 1;
2730  while(true)
2731  {
2733  xmlreader::XmlReader::Text::NONE, &name, &nsId);
2734 
2736  {
2737  if (name == "object" || name == "placeholder")
2738  {
2739  pCurrentChild = handleObject(pParent, pAtkProps, reader).get();
2740 
2741  bool bObjectInserted = pCurrentChild && pParent != pCurrentChild;
2742 
2743  if (bObjectInserted)
2744  {
2745  //Internal-children default in glade to not having their visible bits set
2746  //even though they are visible (generally anyway)
2747  if (!sInternalChild.isEmpty())
2748  pCurrentChild->Show();
2749 
2750  //Select the first page if it's a notebook
2751  if (pCurrentChild->GetType() == WindowType::TABCONTROL)
2752  {
2753  TabControl *pTabControl = static_cast<TabControl*>(pCurrentChild);
2754  pTabControl->SetCurPageId(pTabControl->GetPageId(0));
2755 
2756  //To-Do add reorder capability to the TabControl
2757  }
2758  else
2759  {
2760  // We want to sort labels before contents of frames
2761  // for keyboard traversal, especially if there
2762  // are multiple widgets using the same mnemonic
2763  if (sType == "label")
2764  {
2765  if (VclFrame *pFrameParent = dynamic_cast<VclFrame*>(pParent))
2766  pFrameParent->designate_label(pCurrentChild);
2767  }
2768  if (sInternalChild.startsWith("vbox") || sInternalChild.startsWith("messagedialog-vbox"))
2769  {
2770  if (Dialog *pBoxParent = dynamic_cast<Dialog*>(pParent))
2771  pBoxParent->set_content_area(static_cast<VclBox*>(pCurrentChild)); // FIXME-VCLPTR
2772  }
2773  else if (sInternalChild.startsWith("action_area") || sInternalChild.startsWith("messagedialog-action_area"))
2774  {
2775  vcl::Window *pContentArea = pCurrentChild->GetParent();
2776  if (Dialog *pBoxParent = dynamic_cast<Dialog*>(pContentArea ? pContentArea->GetParent() : nullptr))
2777  {
2778  pBoxParent->set_action_area(static_cast<VclButtonBox*>(pCurrentChild)); // FIXME-VCLPTR
2779  }
2780  }
2781 
2782  bool bIsButtonBox = dynamic_cast<VclButtonBox*>(pCurrentChild) != nullptr;
2783 
2784  //To-Do make reorder a virtual in Window, move this foo
2785  //there and see above
2786  std::vector<vcl::Window*> aChilds;
2787  for (vcl::Window* pChild = pCurrentChild->GetWindow(GetWindowType::FirstChild); pChild;
2788  pChild = pChild->GetWindow(GetWindowType::Next))
2789  {
2790  if (bIsButtonBox)
2791  {
2792  if (PushButton* pPushButton = dynamic_cast<PushButton*>(pChild))
2793  pPushButton->setAction(true);
2794  }
2795 
2796  aChilds.push_back(pChild);
2797  }
2798 
2799  //sort child order within parent so that tabbing
2800  //between controls goes in a visually sensible sequence
2801  std::stable_sort(aChilds.begin(), aChilds.end(), sortIntoBestTabTraversalOrder(this));
2802  BuilderUtils::reorderWithinParent(aChilds, bIsButtonBox);
2803  }
2804  }
2805  }
2806  else if (name == "packing")
2807  {
2808  handlePacking(pCurrentChild, pParent, reader);
2809  }
2810  else if (name == "interface")
2811  {
2812  while (reader.nextAttribute(&nsId, &name))
2813  {
2814  if (name == "domain")
2815  {
2816  name = reader.getAttributeValue(false);
2817  sType = OString(name.begin, name.length);
2818  m_pParserState->m_aResLocale = Translate::Create(sType);
2819  }
2820  }
2821  ++nLevel;
2822  }
2823  else
2824  ++nLevel;
2825  }
2826 
2828  --nLevel;
2829 
2830  if (!nLevel)
2831  break;
2832 
2834  break;
2835  }
2836 }
2837 
2839 {
2840  xmlreader::Span span;
2841  int nsId;
2842 
2843  OString sProperty;
2844  OString sValue;
2845 
2846  while (reader.nextAttribute(&nsId, &span))
2847  {
2848  if (span == "name")
2849  {
2850  span = reader.getAttributeValue(false);
2851  sProperty = OString(span.begin, span.length);
2852  }
2853  else if (span == "value")
2854  {
2855  span = reader.getAttributeValue(false);
2856  sValue = OString(span.begin, span.length);
2857  }
2858  }
2859 
2860  if (!sProperty.isEmpty())
2861  rMap[sProperty] = OUString::fromUtf8(sValue);
2862 }
2863 
2865 {
2866  xmlreader::Span span;
2867  int nsId;
2868 
2869  OString sProperty;
2870  OString sValue;
2871 
2872  while (reader.nextAttribute(&nsId, &span))
2873  {
2874  if (span == "type")
2875  {
2876  span = reader.getAttributeValue(false);
2877  sProperty = OString(span.begin, span.length);
2878  }
2879  else if (span == "target")
2880  {
2881  span = reader.getAttributeValue(false);
2882  sValue = OString(span.begin, span.length);
2883  sal_Int32 nDelim = sValue.indexOf(':');
2884  if (nDelim != -1)
2885  sValue = sValue.copy(0, nDelim);
2886  }
2887  }
2888 
2889  if (!sProperty.isEmpty())
2890  rMap[sProperty] = OUString::fromUtf8(sValue);
2891 }
2892 
2894 {
2895  xmlreader::Span span;
2896  int nsId;
2897 
2898  OString sProperty;
2899 
2900  while (reader.nextAttribute(&nsId, &span))
2901  {
2902  if (span == "type")
2903  {
2904  span = reader.getAttributeValue(false);
2905  sProperty = OString(span.begin, span.length);
2906  }
2907  }
2908 
2909  if (!sProperty.isEmpty())
2910  rMap["role"] = OUString::fromUtf8(sProperty);
2911 }
2912 
2913 void VclBuilder::handleRow(xmlreader::XmlReader &reader, const OString &rID)
2914 {
2915  int nLevel = 1;
2916 
2917  ListStore::row aRow;
2918 
2919  while(true)
2920  {
2921  xmlreader::Span name;
2922  int nsId;
2923 
2925  xmlreader::XmlReader::Text::NONE, &name, &nsId);
2926 
2928  break;
2929 
2931  {
2932  ++nLevel;
2933  if (name == "col")
2934  {
2935  bool bTranslated = false;
2936  sal_uInt32 nId = 0;
2937  OString sContext;
2938 
2939  while (reader.nextAttribute(&nsId, &name))
2940  {
2941  if (name == "id")
2942  {
2943  name = reader.getAttributeValue(false);
2944  nId = OString(name.begin, name.length).toUInt32();
2945  }
2946  else if (nId == 0 && name == "translatable" && reader.getAttributeValue(false) == "yes")
2947  {
2948  bTranslated = true;
2949  }
2950  else if (name == "context")
2951  {
2952  name = reader.getAttributeValue(false);
2953  sContext = OString(name.begin, name.length);
2954  }
2955  }
2956 
2957  (void)reader.nextItem(
2958  xmlreader::XmlReader::Text::Raw, &name, &nsId);
2959 
2960  OString sValue(name.begin, name.length);
2961  OUString sFinalValue;
2962  if (bTranslated)
2963  {
2964  if (!sContext.isEmpty())
2965  sValue = sContext + "\004" + sValue;
2966  sFinalValue = Translate::get(sValue.getStr(), m_pParserState->m_aResLocale);
2967  }
2968  else
2969  sFinalValue = OUString::fromUtf8(sValue);
2970 
2971 
2972  if (aRow.size() < nId+1)
2973  aRow.resize(nId+1);
2974  aRow[nId] = sFinalValue;
2975  }
2976  }
2977 
2979  {
2980  --nLevel;
2981  }
2982 
2983  if (!nLevel)
2984  break;
2985  }
2986 
2987  m_pParserState->m_aModels[rID].m_aEntries.push_back(aRow);
2988 }
2989 
2990 void VclBuilder::handleListStore(xmlreader::XmlReader &reader, const OString &rID, std::string_view rClass)
2991 {
2992  int nLevel = 1;
2993 
2994  while(true)
2995  {
2996  xmlreader::Span name;
2997  int nsId;
2998 
3000  xmlreader::XmlReader::Text::NONE, &name, &nsId);
3001 
3003  break;
3004 
3006  {
3007  if (name == "row")
3008  {
3009  bool bNotTreeStore = rClass != "GtkTreeStore";
3010  if (bNotTreeStore)
3011  handleRow(reader, rID);
3012  assert(bNotTreeStore && "gtk, as the time of writing, doesn't support data in GtkTreeStore serialization");
3013  }
3014  else
3015  ++nLevel;
3016  }
3017 
3019  {
3020  --nLevel;
3021  }
3022 
3023  if (!nLevel)
3024  break;
3025  }
3026 }
3027 
3029 {
3030  int nLevel = 1;
3031 
3033 
3034  while (true)
3035  {
3036  xmlreader::Span name;
3037  int nsId;
3038 
3040  xmlreader::XmlReader::Text::NONE, &name, &nsId);
3041 
3043  break;
3044 
3046  {
3047  ++nLevel;
3048  if (name == "property")
3049  collectProperty(reader, aProperties);
3050  }
3051 
3053  {
3054  --nLevel;
3055  }
3056 
3057  if (!nLevel)
3058  break;
3059  }
3060 
3061  return aProperties;
3062 }
3063 
3064 void VclBuilder::applyAtkProperties(vcl::Window *pWindow, const stringmap& rProperties)
3065 {
3066  assert(pWindow);
3067  for (auto const& prop : rProperties)
3068  {
3069  const OString &rKey = prop.first;
3070  const OUString &rValue = prop.second;
3071 
3072  if (pWindow && rKey.match("AtkObject::"))
3073  pWindow->set_property(rKey.copy(RTL_CONSTASCII_LENGTH("AtkObject::")), rValue);
3074  else
3075  SAL_WARN("vcl.builder", "unhandled atk prop: " << rKey);
3076  }
3077 }
3078 
3079 std::vector<ComboBoxTextItem> VclBuilder::handleItems(xmlreader::XmlReader &reader) const
3080 {
3081  int nLevel = 1;
3082 
3083  std::vector<ComboBoxTextItem> aItems;
3084 
3085  while(true)
3086  {
3087  xmlreader::Span name;
3088  int nsId;
3089 
3091  xmlreader::XmlReader::Text::NONE, &name, &nsId);
3092 
3094  break;
3095 
3097  {
3098  ++nLevel;
3099  if (name == "item")
3100  {
3101  bool bTranslated = false;
3102  OString sContext, sId;
3103 
3104  while (reader.nextAttribute(&nsId, &name))
3105  {
3106  if (name == "translatable" && reader.getAttributeValue(false) == "yes")
3107  {
3108  bTranslated = true;
3109  }
3110  else if (name == "context")
3111  {
3112  name = reader.getAttributeValue(false);
3113  sContext = OString(name.begin, name.length);
3114  }
3115  else if (name == "id")
3116  {
3117  name = reader.getAttributeValue(false);
3118  sId = OString(name.begin, name.length);
3119  }
3120  }
3121 
3122  (void)reader.nextItem(
3123  xmlreader::XmlReader::Text::Raw, &name, &nsId);
3124 
3125  OString sValue(name.begin, name.length);
3126  OUString sFinalValue;
3127  if (bTranslated)
3128  {
3129  if (!sContext.isEmpty())
3130  sValue = sContext + "\004" + sValue;
3131  sFinalValue = Translate::get(sValue.getStr(), m_pParserState->m_aResLocale);
3132  }
3133  else
3134  sFinalValue = OUString::fromUtf8(sValue);
3135 
3136  if (m_pStringReplace)
3137  sFinalValue = (*m_pStringReplace)(sFinalValue);
3138 
3139  aItems.emplace_back(sFinalValue, sId);
3140  }
3141  }
3142 
3144  {
3145  --nLevel;
3146  }
3147 
3148  if (!nLevel)
3149  break;
3150  }
3151 
3152  return aItems;
3153 }
3154 
3155 VclPtr<Menu> VclBuilder::handleMenu(xmlreader::XmlReader &reader, const OString &rID, bool bMenuBar)
3156 {
3157  VclPtr<Menu> pCurrentMenu;
3158  if (bMenuBar)
3159  pCurrentMenu = VclPtr<MenuBar>::Create();
3160  else
3161  pCurrentMenu = VclPtr<PopupMenu>::Create();
3162 
3163  pCurrentMenu->set_id(OStringToOUString(rID, RTL_TEXTENCODING_UTF8));
3164 
3165  int nLevel = 1;
3166 
3168 
3169  while(true)
3170  {
3171  xmlreader::Span name;
3172  int nsId;
3173 
3175  xmlreader::XmlReader::Text::NONE, &name, &nsId);
3176 
3178  break;
3179 
3181  {
3182  if (name == "child")
3183  {
3184  handleMenuChild(pCurrentMenu, reader);
3185  }
3186  else
3187  {
3188  ++nLevel;
3189  if (name == "property")
3190  collectProperty(reader, aProperties);
3191  }
3192  }
3193 
3195  {
3196  --nLevel;
3197  }
3198 
3199  if (!nLevel)
3200  break;
3201  }
3202 
3203  m_aMenus.emplace_back(rID, pCurrentMenu);
3204 
3205  return pCurrentMenu;
3206 }
3207 
3209 {
3210  xmlreader::Span name;
3211  int nsId;
3212 
3213  int nLevel = 1;
3214  while(true)
3215  {
3217  xmlreader::XmlReader::Text::NONE, &name, &nsId);
3218 
3220  {
3221  if (name == "object" || name == "placeholder")
3222  {
3223  handleMenuObject(pParent, reader);
3224  }
3225  else
3226  ++nLevel;
3227  }
3228 
3230  --nLevel;
3231 
3232  if (!nLevel)
3233  break;
3234 
3236  break;
3237  }
3238 }
3239 
3241 {
3242  OString sClass;
3243  OString sID;
3244  OUString sCustomProperty;
3245  PopupMenu *pSubMenu = nullptr;
3246 
3247  xmlreader::Span name;
3248  int nsId;
3249 
3250  while (reader.nextAttribute(&nsId, &name))
3251  {
3252  if (name == "class")
3253  {
3254  name = reader.getAttributeValue(false);
3255  sClass = OString(name.begin, name.length);
3256  }
3257  else if (name == "id")
3258  {
3259  name = reader.getAttributeValue(false);
3260  sID = OString(name.begin, name.length);
3261  if (m_bLegacy)
3262  {
3263  sal_Int32 nDelim = sID.indexOf(':');
3264  if (nDelim != -1)
3265  {
3266  sCustomProperty = OUString::fromUtf8(sID.subView(nDelim+1));
3267  sID = sID.copy(0, nDelim);
3268  }
3269  }
3270  }
3271  }
3272 
3273  int nLevel = 1;
3274 
3276  stringmap aAtkProperties;
3277  accelmap aAccelerators;
3278 
3279  if (!sCustomProperty.isEmpty())
3280  aProperties[OString("customproperty")] = sCustomProperty;
3281 
3282  while(true)
3283  {
3285  xmlreader::XmlReader::Text::NONE, &name, &nsId);
3286 
3288  break;
3289 
3291  {
3292  if (name == "child")
3293  {
3294  size_t nChildMenuIdx = m_aMenus.size();
3295  handleChild(nullptr, &aAtkProperties, reader);
3296  bool bSubMenuInserted = m_aMenus.size() > nChildMenuIdx;
3297  if (bSubMenuInserted)
3298  pSubMenu = dynamic_cast<PopupMenu*>(m_aMenus[nChildMenuIdx].m_pMenu.get());
3299  }
3300  else
3301  {
3302  ++nLevel;
3303  if (name == "property")
3304  collectProperty(reader, aProperties);
3305  else if (name == "accelerator")
3306  collectAccelerator(reader, aAccelerators);
3307  }
3308  }
3309 
3311  {
3312  --nLevel;
3313  }
3314 
3315  if (!nLevel)
3316  break;
3317  }
3318 
3319  insertMenuObject(pParent, pSubMenu, sClass, sID, aProperties, aAtkProperties, aAccelerators);
3320 }
3321 
3323 {
3324  m_pParserState->m_aSizeGroups.emplace_back();
3325  SizeGroup &rSizeGroup = m_pParserState->m_aSizeGroups.back();
3326 
3327  int nLevel = 1;
3328 
3329  while(true)
3330  {
3331  xmlreader::Span name;
3332  int nsId;
3333 
3335  xmlreader::XmlReader::Text::NONE, &name, &nsId);
3336 
3338  break;
3339 
3341  {
3342  ++nLevel;
3343  if (name == "widget")
3344  {
3345  while (reader.nextAttribute(&nsId, &name))
3346  {
3347  if (name == "name")
3348  {
3349  name = reader.getAttributeValue(false);
3350  OString sWidget(name.begin, name.length);
3351  sal_Int32 nDelim = sWidget.indexOf(':');
3352  if (nDelim != -1)
3353  sWidget = sWidget.copy(0, nDelim);
3354  rSizeGroup.m_aWidgets.push_back(sWidget);
3355  }
3356  }
3357  }
3358  else
3359  {
3360  if (name == "property")
3361  collectProperty(reader, rSizeGroup.m_aProperties);
3362  }
3363  }
3364 
3366  {
3367  --nLevel;
3368  }
3369 
3370  if (!nLevel)
3371  break;
3372  }
3373 }
3374 
3375 namespace
3376 {
3377  vcl::KeyCode makeKeyCode(const std::pair<OString,OString> &rKey)
3378  {
3379  bool bShift = rKey.second.indexOf("GDK_SHIFT_MASK") != -1;
3380  bool bMod1 = rKey.second.indexOf("GDK_CONTROL_MASK") != -1;
3381  bool bMod2 = rKey.second.indexOf("GDK_ALT_MASK") != -1;
3382  bool bMod3 = rKey.second.indexOf("GDK_MOD2_MASK") != -1;
3383 
3384  if (rKey.first == "Insert")
3385  return vcl::KeyCode(KEY_INSERT, bShift, bMod1, bMod2, bMod3);
3386  else if (rKey.first == "Delete")
3387  return vcl::KeyCode(KEY_DELETE, bShift, bMod1, bMod2, bMod3);
3388  else if (rKey.first == "Return")
3389  return vcl::KeyCode(KEY_RETURN, bShift, bMod1, bMod2, bMod3);
3390  else if (rKey.first == "Up")
3391  return vcl::KeyCode(KEY_UP, bShift, bMod1, bMod2, bMod3);
3392  else if (rKey.first == "Down")
3393  return vcl::KeyCode(KEY_DOWN, bShift, bMod1, bMod2, bMod3);
3394  else if (rKey.first == "Left")
3395  return vcl::KeyCode(KEY_LEFT, bShift, bMod1, bMod2, bMod3);
3396  else if (rKey.first == "Right")
3397  return vcl::KeyCode(KEY_RIGHT, bShift, bMod1, bMod2, bMod3);
3398  else if (rKey.first == "asterisk")
3399  return vcl::KeyCode(KEY_MULTIPLY, bShift, bMod1, bMod2, bMod3);
3400  else if (rKey.first.getLength() > 1 && rKey.first[0] == 'F')
3401  {
3402  sal_uInt32 nIndex = rKey.first.copy(1).toUInt32();
3403  assert(nIndex >= 1 && nIndex <= 26);
3404  return vcl::KeyCode(KEY_F1 + nIndex - 1, bShift, bMod1, bMod2, bMod3);
3405  }
3406 
3407  assert (rKey.first.getLength() == 1);
3408  char cChar = rKey.first.toChar();
3409 
3410  if (cChar >= 'a' && cChar <= 'z')
3411  return vcl::KeyCode(KEY_A + (cChar - 'a'), bShift, bMod1, bMod2, bMod3);
3412  else if (cChar >= 'A' && cChar <= 'Z')
3413  return vcl::KeyCode(KEY_A + (cChar - 'A'), bShift, bMod1, bMod2, bMod3);
3414  else if (cChar >= '0' && cChar <= '9')
3415  return vcl::KeyCode(KEY_0 + (cChar - 'A'), bShift, bMod1, bMod2, bMod3);
3416 
3417  return vcl::KeyCode(cChar, bShift, bMod1, bMod2, bMod3);
3418  }
3419 }
3420 
3421 void VclBuilder::insertMenuObject(Menu *pParent, PopupMenu *pSubMenu, const OString &rClass, const OString &rID,
3422  stringmap &rProps, stringmap &rAtkProps, accelmap &rAccels)
3423 {
3424  sal_uInt16 nOldCount = pParent->GetItemCount();
3425  sal_uInt16 nNewId = ++m_pParserState->m_nLastMenuItemId;
3426 
3427  if(rClass == "NotebookBarAddonsMenuMergePoint")
3428  {
3429  NotebookBarAddonsMerger::MergeNotebookBarMenuAddons(pParent, nNewId, rID, *m_pNotebookBarAddonsItem);
3430  m_pParserState->m_nLastMenuItemId = pParent->GetItemCount();
3431  }
3432  else if (rClass == "GtkMenuItem")
3433  {
3434  OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps)));
3435  OUString aCommand(extractActionName(rProps));
3436  pParent->InsertItem(nNewId, sLabel, MenuItemBits::NONE , rID);
3437  pParent->SetItemCommand(nNewId, aCommand);
3438  if (pSubMenu)
3439  pParent->SetPopupMenu(nNewId, pSubMenu);
3440  }
3441  else if (rClass == "GtkCheckMenuItem")
3442  {
3443  OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps)));
3444  OUString aCommand(extractActionName(rProps));
3445  pParent->InsertItem(nNewId, sLabel, MenuItemBits::CHECKABLE, rID);
3446  pParent->SetItemCommand(nNewId, aCommand);
3447  }
3448  else if (rClass == "GtkRadioMenuItem")
3449  {
3450  OUString sLabel(BuilderUtils::convertMnemonicMarkup(extractLabel(rProps)));
3451  OUString aCommand(extractActionName(rProps));
3452  pParent->InsertItem(nNewId, sLabel, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK, rID);
3453  pParent->SetItemCommand(nNewId, aCommand);
3454  }
3455  else if (rClass == "GtkSeparatorMenuItem")
3456  {
3457  pParent->InsertSeparator(rID);
3458  }
3459 
3460  SAL_WARN_IF(nOldCount == pParent->GetItemCount(), "vcl.builder", "probably need to implement " << rClass);
3461 
3462  if (nOldCount != pParent->GetItemCount())
3463  {
3464  pParent->SetHelpId(nNewId, m_sHelpRoot + rID);
3465  if (!extractVisible(rProps))
3466  pParent->HideItem(nNewId);
3467 
3468  for (auto const& prop : rProps)
3469  {
3470  const OString &rKey = prop.first;
3471  const OUString &rValue = prop.second;
3472 
3473  if (rKey == "tooltip-markup")
3474  pParent->SetTipHelpText(nNewId, rValue);
3475  else if (rKey == "tooltip-text")
3476  pParent->SetTipHelpText(nNewId, rValue);
3477  else
3478  SAL_INFO("vcl.builder", "unhandled property: " << rKey);
3479  }
3480 
3481  for (auto const& prop : rAtkProps)
3482  {
3483  const OString &rKey = prop.first;
3484  const OUString &rValue = prop.second;
3485 
3486  if (rKey == "AtkObject::accessible-name")
3487  pParent->SetAccessibleName(nNewId, rValue);
3488  else if (rKey == "AtkObject::accessible-description")
3489  pParent->SetAccessibleDescription(nNewId, rValue);
3490  else
3491  SAL_INFO("vcl.builder", "unhandled atk property: " << rKey);
3492  }
3493 
3494  for (auto const& accel : rAccels)
3495  {
3496  const OString &rSignal = accel.first;
3497  const auto &rValue = accel.second;
3498 
3499  if (rSignal == "activate")
3500  pParent->SetAccelKey(nNewId, makeKeyCode(rValue));
3501  else
3502  SAL_INFO("vcl.builder", "unhandled accelerator for: " << rSignal);
3503  }
3504  }
3505 
3506  rProps.clear();
3507 }
3508 
3511 template<typename T> static bool insertItems(vcl::Window *pWindow, VclBuilder::stringmap &rMap,
3512  std::vector<std::unique_ptr<OUString>>& rUserData,
3513  const std::vector<ComboBoxTextItem> &rItems)
3514 {
3515  T *pContainer = dynamic_cast<T*>(pWindow);
3516  if (!pContainer)
3517  return false;
3518 
3519  sal_uInt16 nActiveId = extractActive(rMap);
3520  for (auto const& item : rItems)
3521  {
3522  sal_Int32 nPos = pContainer->InsertEntry(item.m_sItem);
3523  if (!item.m_sId.isEmpty())
3524  {
3525  rUserData.emplace_back(std::make_unique<OUString>(OUString::fromUtf8(item.m_sId)));
3526  pContainer->SetEntryData(nPos, rUserData.back().get());
3527  }
3528  }
3529  if (nActiveId < rItems.size())
3530  pContainer->SelectEntryPos(nActiveId);
3531 
3532  return true;
3533 }
3534 
3536 {
3537  OString sClass;
3538  OString sID;
3539  OUString sCustomProperty;
3540 
3541  xmlreader::Span name;
3542  int nsId;
3543 
3544  while (reader.nextAttribute(&nsId, &name))
3545  {
3546  if (name == "class")
3547  {
3548  name = reader.getAttributeValue(false);
3549  sClass = OString(name.begin, name.length);
3550  }
3551  else if (name == "id")
3552  {
3553  name = reader.getAttributeValue(false);
3554  sID = OString(name.begin, name.length);
3555  if (m_bLegacy)
3556  {
3557  sal_Int32 nDelim = sID.indexOf(':');
3558  if (nDelim != -1)
3559  {
3560  sCustomProperty = OUString::fromUtf8(sID.subView(nDelim+1));
3561  sID = sID.copy(0, nDelim);
3562  }
3563  }
3564  }
3565  }
3566 
3567  if (sClass == "GtkListStore" || sClass == "GtkTreeStore")
3568  {
3569  handleListStore(reader, sID, sClass);
3570  return nullptr;
3571  }
3572  else if (sClass == "GtkMenu")
3573  {
3574  handleMenu(reader, sID, false);
3575  return nullptr;
3576  }
3577  else if (sClass == "GtkMenuBar")
3578  {
3579  VclPtr<Menu> xMenu = handleMenu(reader, sID, true);
3580  if (SystemWindow* pTopLevel = pParent ? pParent->GetSystemWindow() : nullptr)
3581  pTopLevel->SetMenuBar(dynamic_cast<MenuBar*>(xMenu.get()));
3582  return nullptr;
3583  }
3584  else if (sClass == "GtkSizeGroup")
3585  {
3586  handleSizeGroup(reader);
3587  return nullptr;
3588  }
3589  else if (sClass == "AtkObject")
3590  {
3591  assert((pParent || pAtkProps) && "must have one set");
3592  assert(!(pParent && pAtkProps) && "must not have both");
3593  auto aAtkProperties = handleAtkObject(reader);
3594  if (pParent)
3595  applyAtkProperties(pParent, aAtkProperties);
3596  if (pAtkProps)
3597  *pAtkProps = aAtkProperties;
3598  return nullptr;
3599  }
3600 
3601  int nLevel = 1;
3602 
3603  stringmap aProperties, aPangoAttributes;
3604  stringmap aAtkAttributes;
3605  std::vector<ComboBoxTextItem> aItems;
3606 
3607  if (!sCustomProperty.isEmpty())
3608  aProperties[OString("customproperty")] = sCustomProperty;
3609 
3610  VclPtr<vcl::Window> pCurrentChild;
3611  while(true)
3612  {
3614  xmlreader::XmlReader::Text::NONE, &name, &nsId);
3615 
3617  break;
3618 
3620  {
3621  if (name == "child")
3622  {
3623  if (!pCurrentChild)
3624  {
3625  pCurrentChild = insertObject(pParent, sClass, sID,
3626  aProperties, aPangoAttributes, aAtkAttributes);
3627  }
3628  handleChild(pCurrentChild, nullptr, reader);
3629  }
3630  else if (name == "items")
3631  aItems = handleItems(reader);
3632  else if (name == "style")
3633  {
3634  int nPriority = 0;
3635  std::vector<vcl::EnumContext::Context> aContext = handleStyle(reader, nPriority);
3636  if (nPriority != 0)
3637  {
3638  vcl::IPrioritable* pPrioritable = dynamic_cast<vcl::IPrioritable*>(pCurrentChild.get());
3639  SAL_WARN_IF(!pPrioritable, "vcl", "priority set for not supported item");
3640  if (pPrioritable)
3641  pPrioritable->SetPriority(nPriority);
3642  }
3643  if (!aContext.empty())
3644  {
3645  vcl::IContext* pContextControl = dynamic_cast<vcl::IContext*>(pCurrentChild.get());
3646  SAL_WARN_IF(!pContextControl, "vcl", "context set for not supported item");
3647  if (pContextControl)
3648  pContextControl->SetContext(aContext);
3649  }
3650  }
3651  else
3652  {
3653  ++nLevel;
3654  if (name == "property")
3655  collectProperty(reader, aProperties);
3656  else if (name == "attribute")
3657  collectPangoAttribute(reader, aPangoAttributes);
3658  else if (name == "relation")
3659  collectAtkRelationAttribute(reader, aAtkAttributes);
3660  else if (name == "role")
3661  collectAtkRoleAttribute(reader, aAtkAttributes);
3662  else if (name == "action-widget")
3663  handleActionWidget(reader);
3664  }
3665  }
3666 
3668  {
3669  --nLevel;
3670  }
3671 
3672  if (!nLevel)
3673  break;
3674  }
3675 
3676  if (sClass == "GtkAdjustment")
3677  {
3678  m_pParserState->m_aAdjustments[sID] = aProperties;
3679  return nullptr;
3680  }
3681  else if (sClass == "GtkTextBuffer")
3682  {
3683  m_pParserState->m_aTextBuffers[sID] = aProperties;
3684  return nullptr;
3685  }
3686 
3687  if (!pCurrentChild)
3688  {
3689  pCurrentChild = insertObject(pParent, sClass, sID, aProperties,
3690  aPangoAttributes, aAtkAttributes);
3691  }
3692 
3693  if (!aItems.empty())
3694  {
3695  // try to fill-in the items
3696  if (!insertItems<ComboBox>(pCurrentChild, aProperties, m_aUserData, aItems))
3697  insertItems<ListBox>(pCurrentChild, aProperties, m_aUserData, aItems);
3698  }
3699 
3700  return pCurrentChild;
3701 }
3702 
3704 {
3705  xmlreader::Span name;
3706  int nsId;
3707 
3708  int nLevel = 1;
3709 
3710  while(true)
3711  {
3713  xmlreader::XmlReader::Text::NONE, &name, &nsId);
3714 
3716  break;
3717 
3719  {
3720  ++nLevel;
3721  if (name == "property")
3722  applyPackingProperty(pCurrent, pParent, reader);
3723  }
3724 
3726  {
3727  --nLevel;
3728  }
3729 
3730  if (!nLevel)
3731  break;
3732  }
3733 }
3734 
3736  vcl::Window *pParent,
3737  xmlreader::XmlReader &reader)
3738 {
3739  if (!pCurrent)
3740  return;
3741 
3742  //ToolBoxItems are not true widgets just elements
3743  //of the ToolBox itself
3744  ToolBox *pToolBoxParent = nullptr;
3745  if (pCurrent == pParent)
3746  pToolBoxParent = dynamic_cast<ToolBox*>(pParent);
3747 
3748  xmlreader::Span name;
3749  int nsId;
3750 
3751  if (pCurrent->GetType() == WindowType::SCROLLWINDOW)
3752  {
3753  auto aFind = m_pParserState->m_aRedundantParentWidgets.find(VclPtr<vcl::Window>(pCurrent));
3754  if (aFind != m_pParserState->m_aRedundantParentWidgets.end())
3755  {
3756  pCurrent = aFind->second;
3757  assert(pCurrent);
3758  }
3759  }
3760 
3761  while (reader.nextAttribute(&nsId, &name))
3762  {
3763  if (name == "name")
3764  {
3765  name = reader.getAttributeValue(false);
3766  OString sKey(name.begin, name.length);
3767  sKey = sKey.replace('_', '-');
3768  (void)reader.nextItem(
3769  xmlreader::XmlReader::Text::Raw, &name, &nsId);
3770  OString sValue(name.begin, name.length);
3771 
3772  if (sKey == "expand" || sKey == "resize")
3773  {
3774  bool bTrue = (!sValue.isEmpty() && (sValue[0] == 't' || sValue[0] == 'T' || sValue[0] == '1'));
3775  if (pToolBoxParent)
3776  pToolBoxParent->SetItemExpand(m_pParserState->m_nLastToolbarId, bTrue);
3777  else
3778  pCurrent->set_expand(bTrue);
3779  continue;
3780  }
3781 
3782  if (pToolBoxParent)
3783  continue;
3784 
3785  if (sKey == "fill")
3786  {
3787  bool bTrue = (!sValue.isEmpty() && (sValue[0] == 't' || sValue[0] == 'T' || sValue[0] == '1'));
3788  pCurrent->set_fill(bTrue);
3789  }
3790  else if (sKey == "pack-type")
3791  {
3792  VclPackType ePackType = (!sValue.isEmpty() && (sValue[0] == 'e' || sValue[0] == 'E')) ? VclPackType::End : VclPackType::Start;
3793  pCurrent->set_pack_type(ePackType);
3794  }
3795  else if (sKey == "left-attach")
3796  {
3797  pCurrent->set_grid_left_attach(sValue.toInt32());
3798  }
3799  else if (sKey == "top-attach")
3800  {
3801  pCurrent->set_grid_top_attach(sValue.toInt32());
3802  }
3803  else if (sKey == "width")
3804  {
3805  pCurrent->set_grid_width(sValue.toInt32());
3806  }
3807  else if (sKey == "height")
3808  {
3809  pCurrent->set_grid_height(sValue.toInt32());
3810  }
3811  else if (sKey == "padding")
3812  {
3813  pCurrent->set_padding(sValue.toInt32());
3814  }
3815  else if (sKey == "position")
3816  {
3817  set_window_packing_position(pCurrent, sValue.toInt32());
3818  }
3819  else if (sKey == "secondary")
3820  {
3821  pCurrent->set_secondary(toBool(sValue));
3822  }
3823  else if (sKey == "non-homogeneous")
3824  {
3825  pCurrent->set_non_homogeneous(toBool(sValue));
3826  }
3827  else if (sKey == "homogeneous")
3828  {
3829  pCurrent->set_non_homogeneous(!toBool(sValue));
3830  }
3831  else
3832  {
3833  SAL_WARN_IF(sKey != "shrink", "vcl.builder", "unknown packing: " << sKey);
3834  }
3835  }
3836  }
3837 }
3838 
3839 std::vector<vcl::EnumContext::Context> VclBuilder::handleStyle(xmlreader::XmlReader &reader, int &nPriority)
3840 {
3841  std::vector<vcl::EnumContext::Context> aContext;
3842 
3843  xmlreader::Span name;
3844  int nsId;
3845 
3846  int nLevel = 1;
3847 
3848  while(true)
3849  {
3851  xmlreader::XmlReader::Text::NONE, &name, &nsId);
3852 
3854  break;
3855 
3857  {
3858  ++nLevel;
3859  if (name == "class")
3860  {
3861  OString classStyle = getStyleClass(reader);
3862 
3863  if (classStyle.startsWith("context-"))
3864  {
3865  OString sContext = classStyle.copy(classStyle.indexOf('-') + 1);
3866  OUString sContext2(sContext.getStr(), sContext.getLength(), RTL_TEXTENCODING_UTF8);
3867  aContext.push_back(vcl::EnumContext::GetContextEnum(sContext2));
3868  }
3869  else if (classStyle.startsWith("priority-"))
3870  {
3871  OString aPriority = classStyle.copy(classStyle.indexOf('-') + 1);
3872  OUString aPriority2(aPriority.getStr(), aPriority.getLength(), RTL_TEXTENCODING_UTF8);
3873  nPriority = aPriority2.toInt32();
3874  }
3875  else if (classStyle != "small-button")
3876  {
3877  SAL_WARN("vcl.builder", "unknown class: " << classStyle);
3878  }
3879  }
3880  }
3881 
3883  {
3884  --nLevel;
3885  }
3886 
3887  if (!nLevel)
3888  break;
3889  }
3890 
3891  return aContext;
3892 }
3893 
3895 {
3896  xmlreader::Span name;
3897  int nsId;
3898  OString aRet;
3899 
3900  while (reader.nextAttribute(&nsId, &name))
3901  {
3902  if (name == "name")
3903  {
3904  name = reader.getAttributeValue(false);
3905  aRet = OString (name.begin, name.length);
3906  }
3907  }
3908 
3909  return aRet;
3910 }
3911 
3913 {
3914  xmlreader::Span name;
3915  int nsId;
3916 
3917  OString sProperty, sContext;
3918 
3919  bool bTranslated = false;
3920 
3921  while (reader.nextAttribute(&nsId, &name))
3922  {
3923  if (name == "name")
3924  {
3925  name = reader.getAttributeValue(false);
3926  sProperty = OString(name.begin, name.length);
3927  }
3928  else if (name == "context")
3929  {
3930  name = reader.getAttributeValue(false);
3931  sContext = OString(name.begin, name.length);
3932  }
3933  else if (name == "translatable" && reader.getAttributeValue(false) == "yes")
3934  {
3935  bTranslated = true;
3936  }
3937  }
3938 
3939  (void)reader.nextItem(xmlreader::XmlReader::Text::Raw, &name, &nsId);
3940  OString sValue(name.begin, name.length);
3941  OUString sFinalValue;
3942  if (bTranslated)
3943  {
3944  if (!sContext.isEmpty())
3945  sValue = sContext + "\004" + sValue;
3946  sFinalValue = Translate::get(sValue.getStr(), m_pParserState->m_aResLocale);
3947  }
3948  else
3949  sFinalValue = OUString::fromUtf8(sValue);
3950 
3951  if (!sProperty.isEmpty())
3952  {
3953  sProperty = sProperty.replace('_', '-');
3954  if (m_pStringReplace)
3955  sFinalValue = (*m_pStringReplace)(sFinalValue);
3956  rMap[sProperty] = sFinalValue;
3957  }
3958 }
3959 
3961 {
3962  xmlreader::Span name;
3963  int nsId;
3964 
3965  OString sResponse;
3966 
3967  while (reader.nextAttribute(&nsId, &name))
3968  {
3969  if (name == "response")
3970  {
3971  name = reader.getAttributeValue(false);
3972  sResponse = OString(name.begin, name.length);
3973  }
3974  }
3975 
3976  (void)reader.nextItem(xmlreader::XmlReader::Text::Raw, &name, &nsId);
3977  OString sID(name.begin, name.length);
3978  sal_Int32 nDelim = sID.indexOf(':');
3979  if (nDelim != -1)
3980  sID = sID.copy(0, nDelim);
3981  set_response(sID, sResponse.toInt32());
3982 }
3983 
3985 {
3986  xmlreader::Span name;
3987  int nsId;
3988 
3989  OString sProperty;
3990  OString sValue;
3991  OString sModifiers;
3992 
3993  while (reader.nextAttribute(&nsId, &name))
3994  {
3995  if (name == "key")
3996  {
3997  name = reader.getAttributeValue(false);
3998  sValue = OString(name.begin, name.length);
3999  }
4000  else if (name == "signal")
4001  {
4002  name = reader.getAttributeValue(false);
4003  sProperty = OString(name.begin, name.length);
4004  }
4005  else if (name == "modifiers")
4006  {
4007  name = reader.getAttributeValue(false);
4008  sModifiers = OString(name.begin, name.length);
4009  }
4010  }
4011 
4012  if (!sProperty.isEmpty() && !sValue.isEmpty())
4013  {
4014  rMap[sProperty] = std::make_pair(sValue, sModifiers);
4015  }
4016 }
4017 
4019 {
4020  return m_aChildren.empty() ? nullptr : m_aChildren[0].m_pWindow.get();
4021 }
4022 
4023 vcl::Window *VclBuilder::get_by_name(std::string_view sID)
4024 {
4025  for (auto const& child : m_aChildren)
4026  {
4027  if (child.m_sID == sID)
4028  return child.m_pWindow;
4029  }
4030 
4031  return nullptr;
4032 }
4033 
4034 PopupMenu *VclBuilder::get_menu(std::string_view sID)
4035 {
4036  for (auto const& menu : m_aMenus)
4037  {
4038  if (menu.m_sID == sID)
4039  return dynamic_cast<PopupMenu*>(menu.m_pMenu.get());
4040  }
4041 
4042  return nullptr;
4043 }
4044 
4045 void VclBuilder::set_response(std::string_view sID, short nResponse)
4046 {
4047  switch (nResponse)
4048  {
4049  case -5:
4050  nResponse = RET_OK;
4051  break;
4052  case -6:
4053  nResponse = RET_CANCEL;
4054  break;
4055  case -7:
4056  nResponse = RET_CLOSE;
4057  break;
4058  case -8:
4059  nResponse = RET_YES;
4060  break;
4061  case -9:
4062  nResponse = RET_NO;
4063  break;
4064  case -11:
4065  nResponse = RET_HELP;
4066  break;
4067  default:
4068  assert(nResponse >= 100 && "keep non-canned responses in range 100+ to avoid collision with vcl RET_*");
4069  break;
4070  }
4071 
4072  for (const auto & child : m_aChildren)
4073  {
4074  if (child.m_sID == sID)
4075  {
4076  PushButton* pPushButton = dynamic_cast<PushButton*>(child.m_pWindow.get());
4077  assert(pPushButton);
4078  Dialog* pDialog = pPushButton->GetParentDialog();
4079  assert(pDialog);
4080  pDialog->add_button(pPushButton, nResponse, false);
4081  return;
4082  }
4083  }
4084 
4085  assert(false);
4086 }
4087 
4088 void VclBuilder::delete_by_name(const OString& sID)
4089 {
4090  auto aI = std::find_if(m_aChildren.begin(), m_aChildren.end(),
4091  [&sID](WinAndId& rItem) { return rItem.m_sID == sID; });
4092  if (aI != m_aChildren.end())
4093  {
4094  aI->m_pWindow.disposeAndClear();
4095  m_aChildren.erase(aI);
4096  }
4097 }
4098 
4100 {
4101  drop_ownership(pWindow);
4102  pWindow->disposeOnce();
4103 }
4104 
4106 {
4107  auto aI = std::find_if(m_aChildren.begin(), m_aChildren.end(),
4108  [&pWindow](WinAndId& rItem) { return rItem.m_pWindow == pWindow; });
4109  if (aI != m_aChildren.end())
4110  m_aChildren.erase(aI);
4111 }
4112 
4113 OString VclBuilder::get_by_window(const vcl::Window *pWindow) const
4114 {
4115  for (auto const& child : m_aChildren)
4116  {
4117  if (child.m_pWindow == pWindow)
4118  return child.m_sID;
4119  }
4120 
4121  return OString();
4122 }
4123 
4125 {
4126  //We've stored the return of new Control, some of these get
4127  //border windows placed around them which are what you get
4128  //from GetChild, so scoot up a level if necessary to get the
4129  //window whose position value we have
4130  const vcl::Window *pPropHolder = pWindow->ImplGetWindow();
4131 
4132  for (auto const& child : m_aChildren)
4133  {
4134  if (child.m_pWindow == pPropHolder)
4135  return child.m_aPackingData;
4136  }
4137 
4138  return PackingData();
4139 }
4140 
4141 void VclBuilder::set_window_packing_position(const vcl::Window *pWindow, sal_Int32 nPosition)
4142 {
4143  for (auto & child : m_aChildren)
4144  {
4145  if (child.m_pWindow == pWindow)
4146  child.m_aPackingData.m_nPosition = nPosition;
4147  }
4148 }
4149 
4151 {
4152  std::map<OString, ListStore>::const_iterator aI = m_pParserState->m_aModels.find(sID);
4153  if (aI != m_pParserState->m_aModels.end())
4154  return &(aI->second);
4155  return nullptr;
4156 }
4157 
4159 {
4160  std::map<OString, TextBuffer>::const_iterator aI = m_pParserState->m_aTextBuffers.find(sID);
4161  if (aI != m_pParserState->m_aTextBuffers.end())
4162  return &(aI->second);
4163  return nullptr;
4164 }
4165 
4167 {
4168  std::map<OString, Adjustment>::const_iterator aI = m_pParserState->m_aAdjustments.find(sID);
4169  if (aI != m_pParserState->m_aAdjustments.end())
4170  return &(aI->second);
4171  return nullptr;
4172 }
4173 
4174 void VclBuilder::mungeModel(ComboBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId)
4175 {
4176  for (auto const& entry : rStore.m_aEntries)
4177  {
4178  const ListStore::row &rRow = entry;
4179  sal_uInt16 nEntry = rTarget.InsertEntry(rRow[0]);
4180  if (rRow.size() > 1)
4181  {
4182  if (m_bLegacy)
4183  {
4184  sal_Int32 nValue = rRow[1].toInt32();
4185  rTarget.SetEntryData(nEntry, reinterpret_cast<void*>(nValue));
4186  }
4187  else
4188  {
4189  if (!rRow[1].isEmpty())
4190  {
4191  m_aUserData.emplace_back(std::make_unique<OUString>(rRow[1]));
4192  rTarget.SetEntryData(nEntry, m_aUserData.back().get());
4193  }
4194  }
4195  }
4196  }
4197  if (nActiveId < rStore.m_aEntries.size())
4198  rTarget.SelectEntryPos(nActiveId);
4199 }
4200 
4201 void VclBuilder::mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId)
4202 {
4203  for (auto const& entry : rStore.m_aEntries)
4204  {
4205  const ListStore::row &rRow = entry;
4206  sal_uInt16 nEntry = rTarget.InsertEntry(rRow[0]);
4207  if (rRow.size() > 1)
4208  {
4209  if (m_bLegacy)
4210  {
4211  sal_Int32 nValue = rRow[1].toInt32();
4212  rTarget.SetEntryData(nEntry, reinterpret_cast<void*>(nValue));
4213  }
4214  else
4215  {
4216  if (!rRow[1].isEmpty())
4217  {
4218  m_aUserData.emplace_back(std::make_unique<OUString>(rRow[1]));
4219  rTarget.SetEntryData(nEntry, m_aUserData.back().get());
4220  }
4221  }
4222  }
4223  }
4224  if (nActiveId < rStore.m_aEntries.size())
4225  rTarget.SelectEntryPos(nActiveId);
4226 }
4227 
4228 void VclBuilder::mungeModel(SvTabListBox& rTarget, const ListStore &rStore, sal_uInt16 nActiveId)
4229 {
4230  for (auto const& entry : rStore.m_aEntries)
4231  {
4232  const ListStore::row &rRow = entry;
4233  auto pEntry = rTarget.InsertEntry(rRow[0]);
4234  if (rRow.size() > 1)
4235  {
4236  if (m_bLegacy)
4237  {
4238  sal_Int32 nValue = rRow[1].toInt32();
4239  pEntry->SetUserData(reinterpret_cast<void*>(nValue));
4240  }
4241  else
4242  {
4243  if (!rRow[1].isEmpty())
4244  {
4245  m_aUserData.emplace_back(std::make_unique<OUString>(rRow[1]));
4246  pEntry->SetUserData(m_aUserData.back().get());
4247  }
4248  }
4249  }
4250  }
4251  if (nActiveId < rStore.m_aEntries.size())
4252  {
4253  SvTreeListEntry* pEntry = rTarget.GetEntry(nullptr, nActiveId);
4254  rTarget.Select(pEntry);
4255  }
4256 }
4257 
4258 void VclBuilder::mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rAdjustment)
4259 {
4260  int nMul = rtl_math_pow10Exp(1, rTarget.GetDecimalDigits());
4261 
4262  for (auto const& elem : rAdjustment)
4263  {
4264  const OString &rKey = elem.first;
4265  const OUString &rValue = elem.second;
4266 
4267  if (rKey == "upper")
4268  {
4269  sal_Int64 nUpper = rValue.toDouble() * nMul;
4270  rTarget.SetMax(nUpper);
4271  rTarget.SetLast(nUpper);
4272  }
4273  else if (rKey == "lower")
4274  {
4275  sal_Int64 nLower = rValue.toDouble() * nMul;
4276  rTarget.SetMin(nLower);
4277  rTarget.SetFirst(nLower);
4278  }
4279  else if (rKey == "value")
4280  {
4281  sal_Int64 nValue = rValue.toDouble() * nMul;
4282  rTarget.SetValue(nValue);
4283  }
4284  else if (rKey == "step-increment")
4285  {
4286  sal_Int64 nSpinSize = rValue.toDouble() * nMul;
4287  rTarget.SetSpinSize(nSpinSize);
4288  }
4289  else
4290  {
4291  SAL_INFO("vcl.builder", "unhandled property :" << rKey);
4292  }
4293  }
4294 }
4295 
4296 void VclBuilder::mungeAdjustment(FormattedField &rTarget, const Adjustment &rAdjustment)
4297 {
4298  double nMaxValue = 0, nMinValue = 0, nValue = 0, nSpinSize = 0;
4299 
4300  for (auto const& elem : rAdjustment)
4301  {
4302  const OString &rKey = elem.first;
4303  const OUString &rValue = elem.second;
4304 
4305  if (rKey == "upper")
4306  nMaxValue = rValue.toDouble();
4307  else if (rKey == "lower")
4308  nMinValue = rValue.toDouble();
4309  else if (rKey == "value")
4310  nValue = rValue.toDouble();
4311  else if (rKey == "step-increment")
4312  nSpinSize = rValue.toDouble();
4313  else
4314  SAL_INFO("vcl.builder", "unhandled property :" << rKey);
4315  }
4316 
4317  Formatter& rFormatter = rTarget.GetFormatter();
4318  rFormatter.SetMinValue(nMinValue);
4319  rFormatter.SetMaxValue(nMaxValue);
4320  rFormatter.SetValue(nValue);
4321  rFormatter.SetSpinSize(nSpinSize);
4322 }
4323 
4324 void VclBuilder::mungeAdjustment(ScrollBar &rTarget, const Adjustment &rAdjustment)
4325 {
4326  for (auto const& elem : rAdjustment)
4327  {
4328  const OString &rKey = elem.first;
4329  const OUString &rValue = elem.second;
4330 
4331  if (rKey == "upper")
4332  rTarget.SetRangeMax(rValue.toInt32());
4333  else if (rKey == "lower")
4334  rTarget.SetRangeMin(rValue.toInt32());
4335  else if (rKey == "value")
4336  rTarget.SetThumbPos(rValue.toInt32());
4337  else if (rKey == "step-increment")
4338  rTarget.SetLineSize(rValue.toInt32());
4339  else if (rKey == "page-increment")
4340  rTarget.SetPageSize(rValue.toInt32());
4341  else
4342  {
4343  SAL_INFO("vcl.builder", "unhandled property :" << rKey);
4344  }
4345  }
4346 }
4347 
4348 void VclBuilder::mungeAdjustment(Slider& rTarget, const Adjustment& rAdjustment)
4349 {
4350  for (auto const& elem : rAdjustment)
4351  {
4352  const OString &rKey = elem.first;
4353  const OUString &rValue = elem.second;
4354 
4355  if (rKey == "upper")
4356  rTarget.SetRangeMax(rValue.toInt32());
4357  else if (rKey == "lower")
4358  rTarget.SetRangeMin(rValue.toInt32());
4359  else if (rKey == "value")
4360  rTarget.SetThumbPos(rValue.toInt32());
4361  else if (rKey == "step-increment")
4362  rTarget.SetLineSize(rValue.toInt32());
4363  else if (rKey == "page-increment")
4364  rTarget.SetPageSize(rValue.toInt32());
4365  else
4366  {
4367  SAL_INFO("vcl.builder", "unhandled property :" << rKey);
4368  }
4369  }
4370 }
4371 
4372 void VclBuilder::mungeTextBuffer(VclMultiLineEdit &rTarget, const TextBuffer &rTextBuffer)
4373 {
4374  for (auto const& elem : rTextBuffer)
4375  {
4376  const OString &rKey = elem.first;
4377  const OUString &rValue = elem.second;
4378 
4379  if (rKey == "text")
4380  rTarget.SetText(rValue);
4381  else
4382  {
4383  SAL_INFO("vcl.builder", "unhandled property :" << rKey);
4384  }
4385  }
4386 }
4387 
4389  : m_nLastToolbarId(0)
4390  , m_nLastMenuItemId(0)
4391 {}
4392 
4393 VclBuilder::MenuAndId::MenuAndId(const OString &rId, Menu *pMenu)
4394  : m_sID(rId)
4395  , m_pMenu(pMenu)
4396 {}
4397 
4398 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetHelpId(ToolBoxItemId nItemId, const OString &rHelpId)
Definition: toolbox2.cxx:1374
static bool toBool(std::string_view rValue)
Definition: builder.cxx:89
void SetRangeMin(tools::Long nNewRange)
Definition: scrbar.cxx:1328
Size GetSizePixel() const
Definition: Image.cxx:86
void delete_by_window(vcl::Window *pWindow)
Definition: builder.cxx:4099
void set_mnemonic_widget(vcl::Window *pWindow)
Definition: fixed.cxx:404
WinBits const WB_DOCKABLE
vcl::Window * ImplGetWindow() const
if this is a proxy return the client, otherwise itself
Definition: window2.cxx:829
void handleMenuObject(Menu *pParent, xmlreader::XmlReader &reader)
Definition: builder.cxx:3240
FieldUnit
MenuAndId(const OString &rId, Menu *pMenu)
Definition: builder.cxx:4393
const LocaleDataWrapper & GetLocaleDataWrapper() const
void HideItem(ToolBoxItemId nItemId)
Convenience method to hide items (via ShowItem).
Definition: toolbox.hxx:408
sal_Int32 nIndex
void SetRangeMax(tools::Long nNewRange)
Definition: slider.cxx:844
void set_height_request_by_rows(int nRows)
Definition: builder.cxx:400
static Image loadThemeImage(const OUString &rFileName)
Definition: fixed.cxx:947
static void thisModule()
Definition: builder.cxx:1425
WinBits const WB_TOGGLE
void extractBuffer(const OString &id, stringmap &rVec)
Definition: builder.cxx:1351
WinBits const WB_SYSTEMWINDOW
#define SAL_DLLEXTENSION
SystemWindow * GetSystemWindow() const
Definition: stacking.cxx:806
WinBits const WB_NOLABEL
void set_border_width(sal_Int32 nBorderWidth)
Definition: window2.cxx:1835
PackingData get_window_packing_data(const vcl::Window *pWindow) const
Definition: builder.cxx:4124
void SetNoAutoCurEntry(bool b)
void SetModeRadioImage(const Image &rImage)
Definition: button.cxx:2619
void group(RadioButton &rOther)
Definition: button.cxx:2179
virtual bool iter_parent(TreeIter &rIter) const =0
VclButtonsType
Definition: vclenum.hxx:244
VclBuilder(vcl::Window *pParent, const OUString &sUIRootDir, const OUString &sUIFile, const OString &sID=OString(), const css::uno::Reference< css::frame::XFrame > &rFrame=css::uno::Reference< css::frame::XFrame >(), bool bLegacy=true, const NotebookBarAddonsItem *pNotebookBarAddonsItem=nullptr)
Definition: builder.cxx:444
void SetMax(sal_Int64 nNewMax)
Definition: field.cxx:582
sal_Int32 get_grid_top_attach() const
Definition: window2.cxx:1823
void set_grid_width(sal_Int32 nCols)
Definition: window2.cxx:1793
static JSInstanceBuilder * CreateAutofilterWindowBuilder(vcl::Window *pParent, const OUString &rUIRoot, const OUString &rUIFile)
void SetModeImage(const Image &rImage)
Definition: button.cxx:131
size_t GetAbsPos(const weld::TreeView &rTreeView, const weld::TreeIter &rIter)
Definition: builder.cxx:406
void set_grid_left_attach(sal_Int32 nAttach)
Definition: window2.cxx:1805
stringmap m_aProperties
Definition: builder.hxx:245
void SetHelpId(sal_uInt16 nItemId, const OString &rHelpId)
Definition: menu.cxx:1156
bool m_bLegacy
Definition: builder.hxx:300
A widget used to choose from a list of items and which has no entry.
Definition: lstbox.hxx:82
void handleSizeGroup(xmlreader::XmlReader &reader)
Definition: builder.cxx:3322
WinBits const WB_HASBUTTONSATROOT
void set_digits(unsigned int digits)
Definition: builder.cxx:329
static void applyAtkProperties(vcl::Window *pWindow, const stringmap &rProperties)
Definition: builder.cxx:3064
Formatter & GetFormatter()
Definition: fmtfield.cxx:1306
void SetCommandHandler(const OUString &aCommand)
Setup handler for UNO commands so that commands like .uno:Something are handled automagically by this...
Definition: button.cxx:117
static Context GetContextEnum(const OUString &rsContextName)
void delete_by_name(const OString &sID)
Definition: builder.cxx:4088
#define SAL_INFO_IF(condition, area, stream)
void set_non_homogeneous(bool bNonHomogeneous)
Definition: window2.cxx:1941
const Image & GetImage() const
Definition: fixed.hxx:170
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:733
constexpr sal_uInt16 KEY_A
Definition: keycodes.hxx:56
constexpr sal_uInt16 KEY_0
Definition: keycodes.hxx:45
void handleRow(xmlreader::XmlReader &reader, const OString &rID)
Definition: builder.cxx:2913
OUString GetLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
Return a label for the given command.
stringmap Adjustment
Definition: builder.hxx:232
void connectFormattedFormatterAdjustment(const OString &id, const OUString &rAdjustment)
Definition: builder.cxx:1270
css::uno::Reference< css::lang::XComponent > m_xFrame
VclPtr< vcl::Window > handleObject(vcl::Window *pParent, stringmap *pAtkProps, xmlreader::XmlReader &reader)
Definition: builder.cxx:3535
virtual Size GetSizePixel() const
Definition: window.cxx:2391
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1261
void SetAccessibleRelationLabelFor(vcl::Window *pLabelFor)
void extractButtonImage(const OString &id, stringmap &rMap, bool bRadio)
Definition: builder.cxx:1370
std::vector< OUString > row
Definition: builder.hxx:218
#define max(a, b)
std::vector< OString > m_aWidgets
Definition: builder.hxx:244
weld::Builder * m_pBuilder
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:540
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
Definition: builder.cxx:181
static void collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap)
Definition: builder.cxx:2838
sal_Int16 nId
TabPage * GetTabPage(sal_uInt16 nPageId) const
Definition: tabctrl.cxx:1894
WinBits const WB_AUTOVSCROLL
void handleListStore(xmlreader::XmlReader &reader, const OString &rID, std::string_view rClass)
Definition: builder.cxx:2990
void set_height_request(sal_Int32 nHeightRequest)
Definition: window2.cxx:1610
virtual weld::Builder * CreateInterimBuilder(vcl::Window *pParent, const OUString &rUIRoot, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId=0)
std::map< OString, std::pair< OString, OString > > accelmap
Definition: builder.hxx:70
WinBits const WB_VSCROLL
void VclBuilderPreload()
Pre-loads all modules containing UI information.
Definition: builder.cxx:1453
void SetHelpId(const OString &)
Definition: window2.cxx:817
char const * begin
stringmap m_aDeferredProperties
Definition: builder.hxx:124
void set_pack_type(VclPackType ePackType)
Definition: window2.cxx:1757
bool IsControlFont() const
Definition: window2.cxx:1066
void SetState(TriState eState)
Definition: button.cxx:3488
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
void SetRangeMax(tools::Long nNewRange)
Definition: scrbar.cxx:1333
void SetType(WindowType nType)
Definition: window2.cxx:967
void SetTipHelpText(sal_uInt16 nItemId, const OUString &rString)
Definition: menu.cxx:1138
ResHookProc GetReadStringHook()
void SetQuickHelpText(const OUString &rHelpText)
Definition: window2.cxx:1225
static OUString MetricToString(FieldUnit rUnit)
Definition: builder.cxx:226
virtual void SetMinValue(double dMin)
Definition: fmtfield.cxx:702
std::vector< row > m_aEntries
Definition: builder.hxx:219
OString m_sHelpRoot
Definition: builder.hxx:294
void HideItem(sal_uInt16 nItemId)
Definition: menu.hxx:297
Dialog * GetParentDialog() const
Definition: window2.cxx:981
static void mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rAdjustment)
Definition: builder.cxx:4258
constexpr sal_uInt16 KEY_UP
Definition: keycodes.hxx:111
#define SAL_DLLPREFIX
Definition: builder.cxx:1446
void SetDropDown(PushButtonDropdownStyle nStyle)
Definition: button.cxx:1549
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const =0
virtual unsigned int get_digits() const =0
void SetSpinSize(sal_Int64 nNewSize)
Definition: field.hxx:107
void SetMin(sal_Int64 nNewMin)
Definition: field.cxx:575
void set_properties(vcl::Window *pWindow, const VclBuilder::stringmap &rProps)
Definition: builder.cxx:2213
constexpr sal_uInt16 KEY_F1
Definition: keycodes.hxx:83
void SetEntryData(sal_Int32 nPos, void *pNewData)
Definition: combobox.cxx:1314
void set_window_packing_position(const vcl::Window *pWindow, sal_Int32 nPosition)
Definition: builder.cxx:4141
static OString getStyleClass(xmlreader::XmlReader &reader)
Definition: builder.cxx:3894
constexpr tools::Long Width() const
static int getImageSize(const stringmap &rMap)
Definition: builder.cxx:1361
WinBits const WB_SCALE
css::uno::Any const & rValue
void SetAccessibleName(sal_uInt16 nItemId, const OUString &rStr)
Definition: tabctrl.cxx:1950
static bool insertItems(vcl::Window *pWindow, VclBuilder::stringmap &rMap, std::vector< std::unique_ptr< OUString >> &rUserData, const std::vector< ComboBoxTextItem > &rItems)
Insert items to a ComboBox or a ListBox.
Definition: builder.cxx:3511
void MergeNotebookBarMenuAddons(Menu *pPopupMenu, sal_Int16 nItemId, const OString &sItemIdName, NotebookBarAddonsItem &aNotebookBarAddonsItem)
WinBits const WB_OWNERDRAWDECORATION
sal_Int64 WinBits
void insertMenuObject(Menu *pParent, PopupMenu *pSubMenu, const OString &rClass, const OString &rID, stringmap &rProps, stringmap &rAtkProps, accelmap &rAccels)
Definition: builder.cxx:3421
virtual weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
void SetControlFont()
Definition: window2.cxx:403
sal_uInt16 nPageId
#define min(a, b)
void EnableAutoSize(bool bAuto)
Definition: listbox.cxx:497
PropertiesInfo aProperties
void get_increments(int &step, int &page, FieldUnit eDestUnit) const
Definition: weld.hxx:2018
void SetPageSize(tools::Long nNewSize)
Definition: scrbar.hxx:125
void SetSymbol(SymbolType eSymbol)
Definition: button.cxx:1535
WinBits const WB_DEFBUTTON
SymbolType
Definition: vclenum.hxx:73
static void mungeTextBuffer(VclMultiLineEdit &rTarget, const TextBuffer &rTextBuffer)
Definition: builder.cxx:4372
o3tl::strong_int< sal_uInt16, struct ToolBoxItemIdTag > ToolBoxItemId
Definition: toolbox.hxx:71
WinBits const WB_VERT
bool isInterimBuilderEnabledForNotebookbar(std::u16string_view rUIFile)
static weld::Builder * CreateInterimBuilder(vcl::Window *pParent, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId=0)
Definition: builder.cxx:194
IMPL_LINK(CustomWeld, DoResize, const Size &, rSize, void)
Definition: customweld.cxx:46
WinBits const WB_HSCROLL
sal_uInt16 GetDecimalDigits() const
Definition: field.hxx:111
void reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition)
Definition: builder.cxx:2272
void SetItemCommand(sal_uInt16 nItemId, const OUString &rCommand)
Definition: menu.cxx:1065
void SetThumbPos(tools::Long nThumbPos)
Definition: slider.cxx:873
std::unique_ptr< weld::SpinButton > m_xSpinButton
Definition: weld.hxx:1911
void set_unit(FieldUnit eUnit)
Definition: builder.cxx:340
VclPtr< vcl::Window > makeObject(vcl::Window *pParent, const OString &rClass, const OString &rID, stringmap &rVec)
Definition: builder.cxx:1552
void mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId)
Definition: builder.cxx:4201
void SetImageAlign(ImageAlign eAlign)
Definition: button.cxx:151
int ConvertValue(int nValue, FieldUnit eInUnit, FieldUnit eOutUnit) const
Definition: builder.cxx:355
virtual SvTreeListEntry * InsertEntry(const OUString &rText, SvTreeListEntry *pParent=nullptr, bool bChildrenOnDemand=false, sal_uInt32 nPos=TREELIST_APPEND, void *pUserData=nullptr) override
Definition: svtabbx.cxx:216
void SetAccessibleRelationMemberOf(vcl::Window *pMemberOf)
void set_width_request(sal_Int32 nWidthRequest)
Definition: window2.cxx:1624
OUString format_number(int nValue) const
Definition: builder.cxx:285
virtual OUString GetText() const
Definition: window.cxx:3044
VclMessageType
Definition: vclenum.hxx:254
void InsertSeparator(const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
Definition: menu.cxx:495
void SetCurPageId(sal_uInt16 nPageId)
Definition: tabctrl.cxx:1804
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::unique_ptr< TreeView > m_xTreeView
Definition: weld.hxx:1822
virtual void InsertItem(const OUString &rCommand, const css::uno::Reference< css::frame::XFrame > &rFrame, ToolBoxItemBits nBits, const Size &rRequestedSize, ImplToolItems::size_type nPos=APPEND)
Insert a command (like '.uno:Save').
Definition: toolbox2.cxx:435
void SetItemWindow(ToolBoxItemId nItemId, vcl::Window *pNewWindow)
Definition: toolbox2.cxx:1080
void MergeNotebookBarAddons(vcl::Window *pParent, const VclBuilder::customMakeWidget &pFunction, const css::uno::Reference< css::frame::XFrame > &m_xFrame, const NotebookBarAddonsItem &aNotebookBarAddonsItem, VclBuilder::stringmap &rMap)
void SetThumbPos(tools::Long nThumbPos)
Definition: scrbar.cxx:1362
WinBits const WB_BEVELBUTTON
bool get_secondary() const
Definition: window2.cxx:1923
TRISTATE_INDET
WinBits const WB_HIDE
sal_uInt16 GetPageCount() const
Definition: tabctrl.cxx:1762
void SetLineSize(tools::Long nNewSize)
Definition: scrbar.hxx:123
static ModuleMap g_aModuleMap
Definition: builder.cxx:1439
void SetPopupMenu(sal_uInt16 nItemId, PopupMenu *pMenu)
Definition: menu.cxx:736
void SetItemExpand(ToolBoxItemId nItemId, bool bExpand)
Definition: toolbox2.cxx:909
void drop_ownership(const vcl::Window *pWindow)
Definition: builder.cxx:4105
void extractGroup(const OString &id, stringmap &rVec)
Definition: builder.cxx:1250
bool IsDockingWindow() const
Definition: window2.cxx:905
std::locale Create(std::string_view aPrefixName, const LanguageTag &rLocale)
void set_fill(bool bFill)
Definition: window2.cxx:1781
OUString GetStock() const
Definition: Image.cxx:79
bool mbDisabled
Definition: window.h:312
constexpr sal_uInt16 KEY_DOWN
Definition: keycodes.hxx:110
void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff)
OUString extractCustomProperty(VclBuilder::stringmap &rMap)
Definition: builder.cxx:2240
static OUString GetUIRootDir()
Definition: dialog.cxx:556
Image GetImageForCommand(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame, vcl::ImageType eImageType)
WinBits const WB_DIALOGCONTROL
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
Use given parent or get a default one using GetDefaultParent(...)
std::map< OUString, std::shared_ptr< NoAutoUnloadModule > > ModuleMap
Definition: builder.cxx:1438
#define DBG_UNHANDLED_EXCEPTION(...)
const OString & GetHelpId() const
Definition: window2.cxx:822
void collectProperty(xmlreader::XmlReader &reader, stringmap &rVec) const
Definition: builder.cxx:3912
ToolBoxItemBits
Definition: vclenum.hxx:50
void clear()
Definition: vclptr.hxx:190
void(* customMakeWidget)(VclPtr< vcl::Window > &rRet, const VclPtr< vcl::Window > &pParent, stringmap &rVec)
These functions create a new widget with parent pParent and return it in rRet.
Definition: builder.hxx:72
void SetAccessibleDescription(sal_uInt16 nItemId, const OUString &rStr)
Definition: tabctrl.cxx:1966
virtual void doDeferredInit(WinBits nBits)
Definition: syswin.cxx:1108
void SetAccessibleDescription(sal_uInt16 nItemId, const OUString &rStr)
Definition: menu.cxx:2340
static vcl::Window * prepareWidgetOwnScrolling(vcl::Window *pParent, WinBits &rWinStyle)
Definition: builder.cxx:1394
#define SAL_MAX_INT32
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
VclPackType
Definition: vclenum.hxx:222
OString get_by_window(const vcl::Window *pWindow) const
Definition: builder.cxx:4113
int i
HeaderBar * GetHeaderBar()
Definition: svtabbx.cxx:533
bool IsSystemWindow() const
Definition: window2.cxx:996
void SetQuickHelpText(ToolBoxItemId nItemId, const OUString &rText)
Definition: toolbox2.cxx:1343
void SetPageText(sal_uInt16 nPageId, const OUString &rText)
Definition: tabctrl.cxx:1904
void set_secondary(bool bSecondary)
Definition: window2.cxx:1929
void SetValue(double dVal)
Definition: fmtfield.cxx:855
#define WB_BUTTONSTYLE
Definition: headbar.hxx:177
void SetItemImage(ToolBoxItemId nItemId, const Image &rImage)
Definition: toolbox2.cxx:943
void SetAccessibleRelationLabeledBy(vcl::Window *pLabeledBy)
void SelectEntryPos(sal_Int32 nPos, bool bSelect=true)
Definition: listbox.cxx:1027
WinBits const WB_SIMPLEMODE
virtual void SetText(const OUString &rStr) override
Definition: ctrl.cxx:95
void handleMenuChild(Menu *pParent, xmlreader::XmlReader &reader)
Definition: builder.cxx:3208
bool m_bToplevelHasDeferredProperties
Definition: builder.hxx:298
WinBits const WB_VCENTER
PopupMenu * get_menu(std::string_view sID)
Definition: builder.cxx:4034
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
Definition: builder.cxx:219
void EnableTriState(bool bTriState=true)
Definition: button.cxx:3510
#define SAL_MIN_INT32
static void collectAtkRelationAttribute(xmlreader::XmlReader &reader, stringmap &rMap)
Definition: builder.cxx:2864
virtual bool iter_next(TreeIter &rIter) const =0
std::map< OString, OUString > stringmap
Definition: builder.hxx:69
vcl::Window * get_widget_root()
Definition: builder.cxx:4018
float u
void add_button(PushButton *pButton, int nResponse, bool bTransferOwnership)
Definition: dialog.cxx:1414
WinBits const WB_SMALLSTYLE
Size get_preferred_size() const
Definition: window2.cxx:1660
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=LISTBOX_APPEND)
Definition: listbox.cxx:937
VclPtr< vcl::Window > m_pParent
Definition: builder.hxx:296
void set_value(int nValue, FieldUnit eValueUnit)
Definition: weld.hxx:1953
void InitHeaderBar(HeaderBar *pHeaderBar)
Definition: svtabbx.cxx:524
WinBits const WB_DROPDOWN
stringmap TextBuffer
Definition: builder.hxx:227
void SetImage(const Image &rImage)
Definition: fixed.cxx:937
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1444
void reorderWithinParent(sal_uInt16 nNewPosition)
Definition: stacking.cxx:162
VclPackType get_pack_type() const
Definition: window2.cxx:1751
virtual void SetMaxValue(double dMax)
Definition: fmtfield.cxx:712
void cleanupWidgetOwnScrolling(vcl::Window *pScrollParent, vcl::Window *pWindow, stringmap &rMap)
Definition: builder.cxx:1412
vcl::Window * GetParent() const
Definition: window2.cxx:1096
WinBits const WB_LEFT
VclPtr< vcl::Window > mpBorderWindow
Definition: window.h:228
void InsertPage(const OString &rPageId, const OUString &rLabel, const Image &rImage, const OUString &rTooltip, VclPtr< vcl::Window > xPage, int nPos=-1)
Definition: ivctrl.cxx:555
void SetStyle(WinBits nStyle)
Definition: window.cxx:1952
WinBits const WB_REPEAT
OUString get(std::string_view sContextAndId, const std::locale &loc)
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
bool TextToValue(const OUString &rStr, double &rValue, sal_Int64 nBaseValue, sal_uInt16 nDecDigits, const LocaleDataWrapper &rLocaleDataWrapper, FieldUnit eUnit)
Definition: field.cxx:1199
void set_increments(int step, int page, FieldUnit eValueUnit)
Definition: weld.hxx:2011
OUString convertMnemonicMarkup(const OUString &rIn)
Definition: builder.cxx:2223
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1035
constexpr sal_uInt16 KEY_RIGHT
Definition: keycodes.hxx:113
InitFlag
Definition: dialog.hxx:43
void handleChild(vcl::Window *pParent, stringmap *pAtkProps, xmlreader::XmlReader &reader)
Definition: builder.cxx:2701
void SetSpaceBetweenEntries(short nSpace)
void applyPackingProperty(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader)
Definition: builder.cxx:3735
void set_grid_top_attach(sal_Int32 nAttach)
Definition: window2.cxx:1829
void set_grid_height(sal_Int32 nRows)
Definition: window2.cxx:1817
bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile)
WinBits const WB_3DLOOK
WinBits const WB_SIZEABLE
void setDeferredProperties()
Definition: builder.cxx:2201
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
Return a label for the given command.
virtual Size GetOptimalSize() const override
Definition: ctrl.cxx:374
void set_id(const OUString &rID)
Sets an ID.
Definition: window.cxx:3909
void extractModel(const OString &id, stringmap &rVec)
Definition: builder.cxx:1340
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:275
void extractMnemonicWidget(const OString &id, stringmap &rMap)
Definition: builder.cxx:1380
const Adjustment * get_adjustment_by_name(const OString &sID) const
Definition: builder.cxx:4166
void SetPageName(sal_uInt16 nPageId, const OString &rName) const
Definition: tabctrl.cxx:1982
void InsertItem(sal_uInt16 nItemId, const OUString &rStr, MenuItemBits nItemBits=MenuItemBits::NONE, const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
Definition: menu.cxx:433
static void collectAtkRoleAttribute(xmlreader::XmlReader &reader, stringmap &rMap)
Definition: builder.cxx:2893
std::unique_ptr< ParserState > m_pParserState
Definition: builder.hxx:301
void SetSmallSymbol()
Definition: button.cxx:531
Definition: menu.hxx:124
static OUString formatPercent(double dNumber, const LanguageTag &rLangTag)
sal_Int32 get_height_request() const
Definition: window2.cxx:1911
const LanguageTag & getLanguageTag() const
void disposeBuilder()
releases references and disposes all children.
Definition: builder.cxx:810
IMPL_LINK_NOARG(HexColorControl, OnAsyncModifyHdl, void *, void)
sal_Int32 length
void connectNumericFormatterAdjustment(const OString &id, const OUString &rAdjustment)
Definition: builder.cxx:1264
void handleActionWidget(xmlreader::XmlReader &reader)
Definition: builder.cxx:3960
WindowType
sal_Int32 get_grid_left_attach() const
Definition: window2.cxx:1799
void handlePacking(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader)
Definition: builder.cxx:3703
void set_id(const OUString &rID)
Sets an ID.
Definition: menu.hxx:405
#define SAL_WARN_IF(condition, area, stream)
void SetAccessibleName(sal_uInt16 nItemId, const OUString &rStr)
Definition: menu.cxx:2318
constexpr tools::Long Height() const
WinBits const WB_BORDER
void SetFirst(sal_Int64 nNewFirst)
Definition: field.hxx:103
Span getAttributeValue(bool fullyNormalize)
void SetRangeMin(tools::Long nNewRange)
Definition: slider.cxx:839
stringmap handleAtkObject(xmlreader::XmlReader &reader)
Definition: builder.cxx:3028
int denormalize(int nValue) const
Definition: builder.cxx:269
static std::vector< vcl::EnumContext::Context > handleStyle(xmlreader::XmlReader &reader, int &nPriority)
Definition: builder.cxx:3839
css::uno::Reference< css::frame::XFrame > m_xFrame
XFrame to be able to extract labels and other properties of the UNO commands (like of ...
Definition: builder.hxx:319
SvTreeListEntry * GetEntry(SvTreeListEntry *pParent, sal_uInt32 nPos) const
vcl::Window * get_label_widget()
Definition: layout.cxx:1498
void handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader)
Definition: builder.cxx:2515
#define SAL_INFO(area, stream)
sal_Int32 get_width_request() const
Definition: window2.cxx:1917
OString m_sID
Definition: builder.hxx:293
const char sBorder[]
VCL_DLLPRIVATE void SetEntryHeight(SvTreeListEntry const *pEntry)
virtual void doDeferredInit(WinBits nBits)
Definition: dockwin.cxx:361
#define MNEMONIC_CHAR
Definition: mnemonic.hxx:48
sal_uInt16 GetPageId(sal_uInt16 nPos) const
Definition: tabctrl.cxx:1767
void SetPopupMenu(PopupMenu *pNewMenu)
Definition: menubtn.cxx:240
sal_uInt16 GetItemCount() const
Definition: menu.cxx:600
tools::Long AdjustWidth(tools::Long n)
Definition: image.hxx:39
vcl::Window * get_by_name(std::string_view sID)
Definition: builder.cxx:4023
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
VclPtr< vcl::Window > mpParent
Definition: window.h:230
std::unique_ptr< NotebookBarAddonsItem > m_pNotebookBarAddonsItem
Definition: builder.hxx:126
virtual bool get_iter_first(TreeIter &rIter) const =0
std::vector< MenuAndId > m_aMenus
Definition: builder.hxx:159
void InsertSeparator(ImplToolItems::size_type nPos=APPEND, sal_uInt16 nPixSize=0)
Definition: toolbox2.cxx:498
void SetItemCommand(ToolBoxItemId nItemId, const OUString &rCommand)
Definition: toolbox2.cxx:1325
OUString aLabel
void SetAccelKey(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode)
Definition: menu.cxx:783
const char * name
const TextBuffer * get_buffer_by_name(const OString &sID) const
Definition: builder.cxx:4158
std::vector< std::pair< OUString, FieldUnit > > FieldUnitStringList
Definition: svdata.hxx:267
void RemovePage(sal_uInt16 nPageId)
Definition: tabctrl.cxx:1670
VclPtr< vcl::Window > insertObject(vcl::Window *pParent, const OString &rClass, const OString &rID, stringmap &rProps, stringmap &rPangoAttributes, stringmap &rAtkProps)
Definition: builder.cxx:2442
Any value
const ListStore * get_model_by_name(const OString &sID) const
Definition: builder.cxx:4150
WinBits const WB_AUTOHSCROLL
bool extractDropdown(VclBuilder::stringmap &rMap)
Definition: builder.cxx:2260
#define SVLIBRARY(Base)
WinBits const WB_TABSTOP
void SetContext(const std::vector< vcl::EnumContext::Context > &aContext)
Definition: IContext.hxx:25
bool set_font_attribute(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1385
static JSInstanceBuilder * CreateDialogBuilder(weld::Widget *pParent, const OUString &rUIRoot, const OUString &rUIFile)
sal_Int16 getRoleFromName(const OString &roleName)
Definition: builder.cxx:2304
void setHeight(tools::Long nHeight)
sal_Int64 ConvertValue(sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, FieldUnit eOutUnit)
Definition: field.cxx:1028
A widget used to choose from a list of items and which has an entry.
Definition: combobox.hxx:38
WindowType GetType() const
Definition: window2.cxx:973
WinBits const WB_HASBUTTONS
constexpr sal_uInt16 KEY_MULTIPLY
Definition: keycodes.hxx:129
OUString sId
void SetTabPage(sal_uInt16 nPageId, TabPage *pPage)
Definition: tabctrl.cxx:1868
VclPtr< Menu > handleMenu(xmlreader::XmlReader &reader, const OString &rID, bool bMenuBar)
Definition: builder.cxx:3155
WinBits const WB_CENTER
void add_to_size_group(const std::shared_ptr< VclSizeGroup > &xGroup)
Definition: window2.cxx:1947
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
int get_value(FieldUnit eDestUnit) const
Definition: weld.hxx:1958
bool nextAttribute(int *nsId, Span *localName)
static bool extractAdjustmentToMap(const OString &id, stringmap &rVec, std::vector< WidgetAdjustmentMap > &rAdjustmentMap)
Definition: builder.cxx:1276
Any result
#define SAL_WARN(area, stream)
VclPtr< vcl::Window > mpRealParent
Definition: window.h:231
void SetPriority(int nPriority)
void ensureDefaultWidthChars(VclBuilder::stringmap &rMap)
Definition: builder.cxx:2252
OUString aCommand
WinBits GetStyle() const
Definition: window2.cxx:952
std::vector< ComboBoxTextItem > handleItems(xmlreader::XmlReader &reader) const
Definition: builder.cxx:3079
void(* f)(TrueTypeTable *)
Definition: ttcr.cxx:482
FieldUnit m_eSrcUnit
Definition: weld.hxx:1910
virtual bool get_row_expanded(const TreeIter &rIter) const =0
OUString getNum(sal_Int64 nNumber, sal_uInt16 nDecimals, bool bUseThousandSep=true, bool bTrailingZeros=true) const
constexpr sal_uInt16 KEY_DELETE
Definition: keycodes.hxx:125
constexpr sal_uInt16 KEY_LEFT
Definition: keycodes.hxx:112
bool Select(SvTreeListEntry *pEntry, bool bSelect=true)
Result nextItem(Text reportText, Span *data, int *nsId)
virtual weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
WinBits const WB_GROUP
void SelectEntryPos(sal_Int32 nPos, bool bSelect=true)
Definition: combobox.cxx:1377
WinBits const WB_CLOSEABLE
sal_Int32 InsertEntry(const OUString &rStr, sal_Int32 nPos=COMBOBOX_APPEND)
Definition: combobox.cxx:882
const FieldUnitStringList & ImplGetFieldUnits()
Definition: svdata.cxx:264
virtual weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIRoot, const OUString &rUIFile)
WinBits const WB_MOVEABLE
static void collectAccelerator(xmlreader::XmlReader &reader, accelmap &rMap)
Definition: builder.cxx:3984
void SetLast(sal_Int64 nNewLast)
Definition: field.hxx:105
void SetPageSize(tools::Long nNewSize)
Definition: slider.hxx:93
void SetEntryData(sal_Int32 nPos, void *pNewData)
Definition: listbox.cxx:1076
void SetAccessibleRole(sal_uInt16 nRole)
WinBits const WB_FLATBUTTON
constexpr sal_uInt16 KEY_INSERT
Definition: keycodes.hxx:124
ToolBoxItemId GetItemId(ImplToolItems::size_type nPos) const
Definition: toolbox2.cxx:741
vcl::Font GetControlFont() const
Definition: window2.cxx:432
void InsertPage(sal_uInt16 nPageId, const OUString &rText, sal_uInt16 nPos=TAB_APPEND)
Definition: tabctrl.cxx:1620
WinBits const WB_STDTABCONTROL
static unsigned int Power10(unsigned int n)
Definition: builder.cxx:261
WinBits const WB_HORZ
EntryTreeView(std::unique_ptr< Entry > xEntry, std::unique_ptr< TreeView > xTreeView)
Definition: builder.cxx:381
WinBits const WB_SPIN
static JSInstanceBuilder * CreateNotebookbarBuilder(vcl::Window *pParent, const OUString &rUIRoot, const OUString &rUIFile, const css::uno::Reference< css::frame::XFrame > &rFrame, sal_uInt64 nWindowId=0)
WinBits const WB_POPUP
static SymbolType mapStockToSymbol(std::u16string_view icon_name)
Definition: builder.cxx:121
bool operator()(const vcl::Window *pA, const vcl::Window *pB) const
Definition: builder.cxx:2636
OUString GetTooltipForCommand(const OUString &rsCommandName, const css::uno::Sequence< css::beans::PropertyValue > &rProperties, const Reference< frame::XFrame > &rxFrame)
WinBits const WB_CLIPCHILDREN
void SetLineSize(tools::Long nNewSize)
Definition: slider.hxx:91
aStr
void EnableAutoSize(bool bAuto)
Definition: combobox.cxx:516
std::unique_ptr< Entry > m_xEntry
Definition: weld.hxx:1821
ImplToolItems::size_type GetItemCount() const
Definition: toolbox2.cxx:707
bool IsEntryVisible(const weld::TreeView &rTreeView, const weld::TreeIter &rIter)
Definition: builder.cxx:424
void SetHelpText(sal_uInt16 nPageId, const OUString &rText)
Definition: tabctrl.cxx:1934
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
Definition: builder.cxx:209
virtual void SetText(const OUString &rStr) override
Definition: vclmedit.cxx:1103
SalInstance * mpDefInst
Definition: svdata.hxx:383
void SetQuickSearch(bool bEnable)
HeaderBarItemBits
Definition: headbar.hxx:180
virtual void SetValue(sal_Int64 nNewValue)
Definition: field.cxx:601
void set_padding(sal_Int32 nPadding)
Definition: window2.cxx:1769
vcl::Window * GetPageParent()
WinBits const WB_ALLOWMENUBAR
void set_response(std::string_view sID, short nResponse)
Definition: builder.cxx:4045
sal_uInt16 nPos
static void addKeyValue(SAL_UNUSED_PARAMETER const OUString &, SAL_UNUSED_PARAMETER const OUString &, SAL_UNUSED_PARAMETER tAddKeyHandling)
sal_uInt16 GetCurPageId() const
Definition: tabctrl.cxx:1838
void set_expand(bool bExpand)
Definition: window2.cxx:1745
virtual void SetSpinSize(double dStep)
Definition: formatter.hxx:226
sal_Int16 nValue
virtual int iter_compare(const TreeIter &a, const TreeIter &b) const =0
virtual int get_iter_depth(const TreeIter &rIter) const =0
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2177
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo