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