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