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