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