LibreOffice Module vcl (master)  1
dialog.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  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <config_feature_desktop.h>
21 
22 #ifdef IOS
23 #include <premac.h>
24 #include <UIKit/UIKit.h>
25 #include <postmac.h>
26 #endif
27 
28 #include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
29 #include <comphelper/lok.hxx>
32 #include <officecfg/Office/Common.hxx>
33 #include <osl/diagnose.h>
34 
35 #include <svdata.hxx>
36 #include <window.h>
37 #include <accel.hxx>
38 #include <brdwin.hxx>
39 
40 #include <rtl/bootstrap.hxx>
41 #include <rtl/strbuf.hxx>
42 #include <sal/log.hxx>
43 
44 #include <vcl/abstdlg.hxx>
45 #include <vcl/builder.hxx>
46 #include <vcl/toolkit/floatwin.hxx>
47 #include <vcl/layout.hxx>
48 #include <vcl/svapp.hxx>
49 #include <vcl/event.hxx>
50 #include <vcl/locktoplevels.hxx>
51 #include <vcl/wrkwin.hxx>
52 #include <vcl/toolkit/button.hxx>
53 #include <vcl/mnemonic.hxx>
54 #include <vcl/toolkit/dialog.hxx>
55 #include <vcl/dialoghelper.hxx>
56 #include <vcl/settings.hxx>
57 #include <vcl/virdev.hxx>
58 #include <vcl/weld.hxx>
59 #include <vcl/uitest/uiobject.hxx>
60 #include <vcl/uitest/logger.hxx>
62 #include <messagedialog.hxx>
63 #include <salframe.hxx>
64 #include <tools/json_writer.hxx>
65 
66 #include <iostream>
67 #include <stack>
68 #include <utility>
69 #include <vector>
70 
71 static OString ImplGetDialogText( Dialog* pDialog )
72 {
73  OUString aErrorStr(pDialog->GetText());
74 
75  OUString sMessage;
76  if (MessageDialog* pMessDialog = dynamic_cast<MessageDialog*>(pDialog))
77  {
78  sMessage = pMessDialog->get_primary_text();
79  }
80 
81  if (!sMessage.isEmpty())
82  {
83  aErrorStr += ", " + sMessage;
84  }
85  return OUStringToOString(aErrorStr, RTL_TEXTENCODING_UTF8);
86 }
87 
88 static bool ImplIsMnemonicCtrl( vcl::Window* pWindow )
89 {
90  if( ! pWindow->GetSettings().GetStyleSettings().GetAutoMnemonic() )
91  return false;
92 
93  if ( (pWindow->GetType() == WindowType::RADIOBUTTON) ||
94  (pWindow->GetType() == WindowType::CHECKBOX) ||
95  (pWindow->GetType() == WindowType::TRISTATEBOX) ||
96  (pWindow->GetType() == WindowType::PUSHBUTTON) )
97  return true;
98 
99  if ( pWindow->GetType() == WindowType::FIXEDTEXT )
100  {
101  FixedText *pText = static_cast<FixedText*>(pWindow);
102  if (pText->get_mnemonic_widget())
103  return true;
104  //This is the legacy pre-layout logic which we retain
105  //until we can be sure we can remove it
106  if (pWindow->GetStyle() & WB_NOLABEL)
107  return false;
108  vcl::Window* pNextWindow = pWindow->GetWindow( GetWindowType::Next );
109  if ( !pNextWindow )
110  return false;
111  pNextWindow = pNextWindow->GetWindow( GetWindowType::Client );
112  return !(!(pNextWindow->GetStyle() & WB_TABSTOP) ||
113  (pNextWindow->GetType() == WindowType::FIXEDTEXT) ||
114  (pNextWindow->GetType() == WindowType::GROUPBOX) ||
115  (pNextWindow->GetType() == WindowType::RADIOBUTTON) ||
116  (pNextWindow->GetType() == WindowType::CHECKBOX) ||
117  (pNextWindow->GetType() == WindowType::TRISTATEBOX) ||
118  (pNextWindow->GetType() == WindowType::PUSHBUTTON));
119  }
120 
121  return false;
122 }
123 
124 // Called by native error dialog popup implementations
126 {
127  ImplSVData* pSVData = ImplGetSVData();
128  if( pSVData->mpIntroWindow )
129  pSVData->mpIntroWindow->Hide();
130 }
131 
133 {
134  const vcl::Window *pLastChild = pChild;
135 
136  if (pChild->GetType() == WindowType::SCROLLWINDOW)
137  pChild = static_cast<const VclScrolledWindow*>(pChild)->get_child();
138  else if (isContainerWindow(*pChild))
139  pChild = pChild->GetWindow(GetWindowType::FirstChild);
140  else
141  pChild = pChild->GetWindow(GetWindowType::Next);
142 
143  while (!pChild)
144  {
145  vcl::Window *pParent = pLastChild->GetParent();
146  if (!pParent)
147  return nullptr;
148  if (pParent == pTopLevel)
149  return nullptr;
150  pLastChild = pParent;
151  pChild = pParent->GetWindow(GetWindowType::Next);
152  }
153 
154  if (isContainerWindow(*pChild))
155  pChild = nextLogicalChildOfParent(pTopLevel, pChild);
156 
157  return const_cast<vcl::Window *>(pChild);
158 }
159 
161 {
162  const vcl::Window *pLastChild = pChild;
163 
164  if (pChild->GetType() == WindowType::SCROLLWINDOW)
165  pChild = static_cast<const VclScrolledWindow*>(pChild)->get_child();
166  else if (isContainerWindow(*pChild))
167  pChild = pChild->GetWindow(GetWindowType::LastChild);
168  else
169  pChild = pChild->GetWindow(GetWindowType::Prev);
170 
171  while (!pChild)
172  {
173  vcl::Window *pParent = pLastChild->GetParent();
174  if (!pParent)
175  return nullptr;
176  if (pParent == pTopLevel)
177  return nullptr;
178  pLastChild = pParent;
179  pChild = pParent->GetWindow(GetWindowType::Prev);
180  }
181 
182  if (isContainerWindow(*pChild))
183  pChild = prevLogicalChildOfParent(pTopLevel, pChild);
184 
185  return const_cast<vcl::Window *>(pChild);
186 }
187 
189 {
190  const vcl::Window *pChild = pTopLevel->GetWindow(GetWindowType::FirstChild);
191  if (pChild && isContainerWindow(*pChild))
192  pChild = nextLogicalChildOfParent(pTopLevel, pChild);
193  return const_cast<vcl::Window *>(pChild);
194 }
195 
197 {
198  const vcl::Window *pChild = pTopLevel->GetWindow(GetWindowType::LastChild);
199  if (pChild && isContainerWindow(*pChild))
200  pChild = prevLogicalChildOfParent(pTopLevel, pChild);
201  return const_cast<vcl::Window *>(pChild);
202 }
203 
205 {
206  MnemonicGenerator aMnemonicGenerator;
207  vcl::Window* pGetChild;
208  vcl::Window* pChild;
209 
210  // register the assigned mnemonics
211  pGetChild = pWindow->GetWindow( GetWindowType::FirstChild );
212  while ( pGetChild )
213  {
214  pChild = pGetChild->ImplGetWindow();
215  aMnemonicGenerator.RegisterMnemonic( pChild->GetText() );
216  pGetChild = nextLogicalChildOfParent(pWindow, pGetChild);
217  }
218 
219  // take the Controls of the dialog into account for TabPages
220  if ( pWindow->GetType() == WindowType::TABPAGE )
221  {
222  vcl::Window* pParent = pWindow->GetParent();
223  if (pParent && pParent->GetType() == WindowType::TABCONTROL )
224  pParent = pParent->GetParent();
225 
226  if (pParent && (pParent->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL )
227  {
228  pGetChild = pParent->GetWindow( GetWindowType::FirstChild );
229  while ( pGetChild )
230  {
231  pChild = pGetChild->ImplGetWindow();
232  aMnemonicGenerator.RegisterMnemonic( pChild->GetText() );
233  pGetChild = nextLogicalChildOfParent(pWindow, pGetChild);
234  }
235  }
236  }
237 
238  // assign mnemonics to Controls which have none
239  pGetChild = pWindow->GetWindow( GetWindowType::FirstChild );
240  while ( pGetChild )
241  {
242  pChild = pGetChild->ImplGetWindow();
243  if ( ImplIsMnemonicCtrl( pChild ) )
244  {
245  OUString aText = pChild->GetText();
246  OUString aNewText = aMnemonicGenerator.CreateMnemonic( aText );
247  if ( aText != aNewText )
248  pChild->SetText( aNewText );
249  }
250 
251  pGetChild = nextLogicalChildOfParent(pWindow, pGetChild);
252  }
253 }
254 
255 static VclButtonBox* getActionArea(Dialog const *pDialog)
256 {
257  VclButtonBox *pButtonBox = nullptr;
258  if (pDialog->isLayoutEnabled())
259  {
262  while (pChild)
263  {
264  pButtonBox = dynamic_cast<VclButtonBox*>(pChild);
265  if (pButtonBox)
266  break;
267  pChild = pChild->GetWindow(GetWindowType::Prev);
268  }
269  }
270  return pButtonBox;
271 }
272 
274 {
275  VclButtonBox* pButtonBox = getActionArea(pDialog);
276  if (pButtonBox)
277  return pButtonBox->GetWindow(GetWindowType::FirstChild);
278  return pDialog->GetWindow(GetWindowType::FirstChild);
279 }
280 
281 static PushButton* ImplGetDefaultButton( Dialog const * pDialog )
282 {
283  vcl::Window* pChild = getActionAreaButtonList(pDialog);
284  while ( pChild )
285  {
286  if ( pChild->ImplIsPushButton() )
287  {
288  PushButton* pPushButton = static_cast<PushButton*>(pChild);
289  if ( pPushButton->ImplIsDefButton() )
290  return pPushButton;
291  }
292 
293  pChild = pChild->GetWindow( GetWindowType::Next );
294  }
295 
296  return nullptr;
297 }
298 
299 static PushButton* ImplGetOKButton( Dialog const * pDialog )
300 {
301  vcl::Window* pChild = getActionAreaButtonList(pDialog);
302  while ( pChild )
303  {
304  if ( pChild->GetType() == WindowType::OKBUTTON )
305  return static_cast<PushButton*>(pChild);
306 
307  pChild = pChild->GetWindow( GetWindowType::Next );
308  }
309 
310  return nullptr;
311 }
312 
313 static PushButton* ImplGetCancelButton( Dialog const * pDialog )
314 {
315  vcl::Window* pChild = getActionAreaButtonList(pDialog);
316 
317  while ( pChild )
318  {
319  if ( pChild->GetType() == WindowType::CANCELBUTTON )
320  return static_cast<PushButton*>(pChild);
321 
322  pChild = pChild->GetWindow( GetWindowType::Next );
323  }
324 
325  return nullptr;
326 }
327 
328 static void ImplMouseAutoPos( Dialog* pDialog )
329 {
330  MouseSettingsOptions nMouseOptions = pDialog->GetSettings().GetMouseSettings().GetOptions();
331  if ( nMouseOptions & MouseSettingsOptions::AutoCenterPos )
332  {
333  Size aSize = pDialog->GetOutputSizePixel();
334  pDialog->SetPointerPosPixel( Point( aSize.Width()/2, aSize.Height()/2 ) );
335  }
336  else if ( nMouseOptions & MouseSettingsOptions::AutoDefBtnPos )
337  {
338  vcl::Window* pWindow = ImplGetDefaultButton( pDialog );
339  if ( !pWindow )
340  pWindow = ImplGetOKButton( pDialog );
341  if ( !pWindow )
342  pWindow = ImplGetCancelButton( pDialog );
343  if ( !pWindow )
344  pWindow = pDialog;
345  Size aSize = pWindow->GetOutputSizePixel();
346  pWindow->SetPointerPosPixel( Point( aSize.Width()/2, aSize.Height()/2 ) );
347  }
348 }
349 
351 {
352  std::vector<VclPtr<PushButton>> maOwnedButtons;
353  std::map<VclPtr<vcl::Window>, short> maResponses;
360 
361  DialogImpl() : mnResult( -1 ), mbStartedModal( false ), m_bLOKTunneling( true ) {}
362 
363 #ifndef NDEBUG
364  short get_response(vcl::Window *pWindow) const
365  {
366  auto aFind = maResponses.find(pWindow);
367  if (aFind != maResponses.end())
368  return aFind->second;
369  return RET_CANCEL;
370  }
371 #endif
372 
374  {
375  for (VclPtr<PushButton> & pOwnedButton : maOwnedButtons)
376  pOwnedButton.disposeAndClear();
377  }
378 };
379 
381 {
382  for (VclPtr<PushButton> & pOwnedButton : mpDialogImpl->maOwnedButtons)
383  pOwnedButton.disposeAndClear();
384 }
385 
387 {
388  mpWindowImpl->mbDialog = true;
389  mbInExecute = false;
390  mbInSyncExecute = false;
391  mbInClose = false;
392  mbModalMode = false;
395  mnMousePositioned = 0;
396  mpDialogImpl.reset(new DialogImpl);
397 }
398 
400 {
401  if (!mpDialogImpl->m_bLOKTunneling)
402  return;
403 
404  Window::PixelInvalidate(pRectangle);
405 }
406 
408 {
410  if (!pParent && !(nStyle & WB_SYSTEMWINDOW))
411  pParent = ImplGetSVData()->maFrameData.mpAppWin;
412 
413  // If Parent is disabled, then we search for a modal dialog
414  // in this frame
415  if (pParent && (!pParent->IsInputEnabled() || pParent->IsInModalMode()))
416  {
417  ImplSVData* pSVData = ImplGetSVData();
418  auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
419  auto it = std::find_if(rExecuteDialogs.rbegin(), rExecuteDialogs.rend(),
420  [&pParent](VclPtr<Dialog>& rDialogPtr) {
421  return pParent->ImplGetFirstOverlapWindow() &&
422  pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild(rDialogPtr, true) &&
423  rDialogPtr->IsReallyVisible() && rDialogPtr->IsEnabled() &&
424  rDialogPtr->IsInputEnabled() && !rDialogPtr->IsInModalMode(); });
425  if (it != rExecuteDialogs.rend())
426  pParent = it->get();
427  }
428 
429  return pParent;
430 }
431 
433 {
434  VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle, BorderWindowStyle::Frame );
435  ImplInit( pBorderWin, nStyle & ~WB_BORDER, nullptr );
436  pBorderWin->mpWindowImpl->mpClientWindow = this;
437  pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
438  mpWindowImpl->mpBorderWindow = pBorderWin;
439  mpWindowImpl->mpRealParent = pParent;
440 
441  return pBorderWin;
442 }
443 
444 void Dialog::ImplInitDialog( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag )
445 {
447 
448  if ( !(nStyle & WB_NODIALOGCONTROL) )
449  nStyle |= WB_DIALOGCONTROL;
450 
451  // Now, all Dialogs are per default system windows !!!
452  nStyle |= WB_SYSTEMWINDOW;
453 
454  if (InitFlag::NoParent == eFlag)
455  {
456  pParent = nullptr;
457  }
458  else if (!pParent) // parent is NULL: get the default Dialog parent
459  {
460  pParent = Dialog::GetDefaultParent(nStyle);
461  }
462 
463  if ( !pParent || (nStyle & WB_SYSTEMWINDOW) ||
464  (pParent->mpWindowImpl->mpFrameData->mbNeedSysWindow && !(nSysWinMode & SystemWindowFlags::NOAUTOMODE)) ||
465  (nSysWinMode & SystemWindowFlags::DIALOG) )
466  {
467  // create window with a small border ?
468  if ((nStyle & WB_ALLOWMENUBAR) || ((nStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE)) == WB_BORDER))
469  {
470  AddBorderWindow(pParent, nStyle);
471  }
472  else
473  {
474  mpWindowImpl->mbFrame = true;
475  mpWindowImpl->mbOverlapWin = true;
476  ImplInit( pParent, (nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_STANDALONE)) | WB_CLOSEABLE, nullptr );
477  // Now set all style bits
478  mpWindowImpl->mnStyle = nStyle;
479  }
480  }
481  else
482  {
483  VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle, BorderWindowStyle::Overlap );
484  ImplInit( pBorderWin, nStyle & ~WB_BORDER, nullptr );
485  pBorderWin->mpWindowImpl->mpClientWindow = this;
486  pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
487  mpWindowImpl->mpBorderWindow = pBorderWin;
488  mpWindowImpl->mpRealParent = pParent;
489  }
490 
492 
494 }
495 
497 {
498  if (IsControlBackground())
499  {
500  // user override
502  }
504  {
505  // NWF background
506  mpWindowImpl->mnNativeBackground = ControlPart::BackgroundDialog;
508  }
509  else
510  {
511  // fallback to settings color
512  rRenderContext.SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
513  }
514 }
515 
517 {
518  // user override
519  if (IsControlBackground())
521  // NWF background
523  {
524  mpWindowImpl->mnNativeBackground = ControlPart::BackgroundDialog;
526  }
527  // fallback to settings color
528  else
529  SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
530 }
531 
533 {
534  if (comphelper::LibreOfficeKit::isActive() && pParent)
535  {
536  if (VclPtr<vcl::Window> pWin = pParent->GetParentWithLOKNotifier())
537  {
538  SetLOKNotifier(pWin->GetLOKNotifier());
539  }
540  }
541 }
542 
544  : SystemWindow( nType, "vcl::Dialog maLayoutIdle" )
545  , mnInitFlag(InitFlag::Default)
546 {
548 }
549 
551 {
552  if (m_pUIBuilder)
553  m_pUIBuilder->disposeBuilder();
554 }
555 
557 {
558  OUString sShareLayer("$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/config/soffice.cfg/");
559  rtl::Bootstrap::expandMacros(sShareLayer);
560  return sShareLayer;
561 }
562 
563 //we can't change sizeable after the fact, so need to defer until we know and then
564 //do the init. Find the real parent stashed in mpDialogParent.
566 {
568  mpDialogParent = nullptr;
569  ImplInitDialog(pParent, nBits | WB_BORDER, mnInitFlag);
570  mbIsDeferredInit = false;
571 }
572 
573 Dialog::Dialog(vcl::Window* pParent, std::u16string_view rID, const OUString& rUIXMLDescription)
574  : SystemWindow(WindowType::DIALOG, "vcl::Dialog maLayoutIdle")
575  , mnInitFlag(InitFlag::Default)
576 {
577  ImplLOKNotifier(pParent);
579  loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription);
580 }
581 
582 Dialog::Dialog(vcl::Window* pParent, WinBits nStyle, InitFlag eFlag)
583  : SystemWindow(WindowType::DIALOG, "vcl::Dialog maLayoutIdle")
584  , mnInitFlag(eFlag)
585 {
586  ImplLOKNotifier(pParent);
588  ImplInitDialog( pParent, nStyle, eFlag );
589 }
590 
592 {
593  mpActionArea.set(pBox);
594  if (pBox)
595  {
596  const DialogStyle& rDialogStyle =
598  pBox->set_border_width(rDialogStyle.action_area_border);
599  }
600 }
601 
603 {
604  mpContentArea.set(pBox);
605 }
606 
608 {
609  const DialogStyle& rDialogStyle =
611  VclBox * pBox2 = static_cast<VclBox*>(pBox);
612  pBox2->set_border_width(rDialogStyle.content_area_border);
613 }
614 
616 {
617  disposeOnce();
618 }
619 
621 {
622  bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling;
623 
624  mpDialogImpl.reset();
628 
629  css::uno::Reference< css::uno::XComponentContext > xContext(
631  css::uno::Reference<css::frame::XGlobalEventBroadcaster> xEventBroadcaster(css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_SET_THROW);
632  css::document::DocumentEvent aObject;
633  aObject.EventName = "DialogClosed";
634  xEventBroadcaster->documentEventOccured(aObject);
635  UITestLogger::getInstance().log(u"Close Dialog");
636 
638  {
639  if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
640  {
641  if (bTunnelingEnabled)
642  pNotifier->notifyWindow(GetLOKWindowId(), "close");
644  }
645  }
646 
648 }
649 
650 IMPL_LINK_NOARG(Dialog, ImplAsyncCloseHdl, void*, void)
651 {
652  Close();
653 }
654 
656 {
657  // first call the base class due to Tab control
658  bool bRet = SystemWindow::EventNotify( rNEvt );
659  if ( !bRet )
660  {
661  if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
662  {
663  const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
664  vcl::KeyCode aKeyCode = pKEvt->GetKeyCode();
665  sal_uInt16 nKeyCode = aKeyCode.GetCode();
666 
667  if ( (nKeyCode == KEY_ESCAPE) &&
668  ((GetStyle() & WB_CLOSEABLE) || ImplGetCancelButton( this ) || ImplGetOKButton( this )) )
669  {
670  // #i89505# for the benefit of slightly mentally challenged implementations
671  // like e.g. SfxModelessDialog which destroy themselves inside Close()
672  // post this Close asynchronous so we can leave our key handler before
673  // we get destroyed
674  PostUserEvent( LINK( this, Dialog, ImplAsyncCloseHdl ), nullptr, true);
675  return true;
676  }
677  }
678  else if ( rNEvt.GetType() == MouseNotifyEvent::GETFOCUS )
679  {
680  // make sure the dialog is still modal
681  // changing focus between application frames may
682  // have re-enabled input for our parent
683  if( mbInExecute && mbModalMode )
684  {
685  ImplSetModalInputMode( false );
686  ImplSetModalInputMode( true );
687 
688  // #93022# def-button might have changed after show
689  if( !mnMousePositioned )
690  {
691  mnMousePositioned = 1;
692  ImplMouseAutoPos( this );
693  }
694 
695  }
696  }
697  }
698 
699  return bRet;
700 }
701 
702 //What we really want here is something that gives the available width and
703 //height of a users screen, taking away the space taken up the OS
704 //taskbar, menus, etc.
706 {
707 #ifndef IOS
708  tools::Long w = rScreenSize.Width();
709  if (w <= 800)
710  w -= 15;
711  else if (w <= 1024)
712  w -= 65;
713  else
714  w -= 115;
715 
716  tools::Long h = rScreenSize.Height();
717  if (h <= 768)
718  h -= 50;
719  else
720  h -= 100;
721 
722  return Size(std::max<tools::Long>(w, 640 - 15),
723  std::max<tools::Long>(h, 480 - 50));
724 #else
725  // Don't bother with ancient magic numbers of unclear relevance on non-desktop apps anyway. It
726  // seems that at least currently in the iOS app, this function is called just once per dialog,
727  // with a rScreenSize parameter of 1x1 (!). This would lead to always returning 625x430 which is
728  // a bit random and needlessly small on an iPad at least. We want something that closely will
729  // just fit on the display in either orientation.
730 
731  // We ignore the rScreenSize as it will be the dummy 1x1 from iosinst.cxx (see "Totally wrong of course").
732  (void) rScreenSize;
733 
734  const int n = std::min<CGFloat>([[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height);
735  return Size(n-10, n-10);
736 #endif
737 }
738 
740 {
741  mpDialogImpl->m_aPopupMenuHdl = rLink;
742 }
743 
745 {
746  mpDialogImpl->m_aInstallLOKNotifierHdl = rLink;
747 }
748 
749 void Dialog::SetLOKTunnelingState(bool bEnabled)
750 {
751  mpDialogImpl->m_bLOKTunneling = bEnabled;
752 }
753 
755 {
756  bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling;
757 
758  if (nType == StateChangedType::InitShow)
759  {
760  DoInitialLayout();
761 
762  const bool bKitActive = comphelper::LibreOfficeKit::isActive();
763  if (bKitActive && bTunnelingEnabled)
764  {
765  std::vector<vcl::LOKPayloadItem> aItems;
766  aItems.emplace_back("type", "dialog");
767  aItems.emplace_back("size", GetSizePixel().toString());
768  if (!GetText().isEmpty())
769  aItems.emplace_back("title", GetText().toUtf8());
770 
771  if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
772  {
773  pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems);
774  pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems);
775  }
776  else
777  {
778  vcl::ILibreOfficeKitNotifier* pViewShell = mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr);
779  if (pViewShell)
780  {
781  SetLOKNotifier(pViewShell);
782  pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
783  }
784  }
785  }
786 
787  if ( !HasChildPathFocus() || HasFocus() )
789  if ( !(GetStyle() & WB_CLOSEABLE) )
790  {
791  if ( ImplGetCancelButton( this ) || ImplGetOKButton( this ) )
792  {
793  if ( ImplGetBorderWindow() )
794  static_cast<ImplBorderWindow*>(ImplGetBorderWindow())->SetCloseButton();
795  }
796  }
797 
798  ImplMouseAutoPos( this );
799  }
800  else if (nType == StateChangedType::Text)
801  {
802  const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier();
803  if (pNotifier && bTunnelingEnabled)
804  {
805  std::vector<vcl::LOKPayloadItem> aPayload;
806  aPayload.emplace_back("title", GetText().toUtf8());
807  pNotifier->notifyWindow(GetLOKWindowId(), "title_changed", aPayload);
808  }
809  }
810 
812 
814  {
816  Invalidate();
817  }
818 
819  if (!mbModalMode && nType == StateChangedType::Visible)
820  {
821  const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier();
822  if (pNotifier && bTunnelingEnabled)
823  {
824  std::vector<vcl::LOKPayloadItem> aPayload;
825  aPayload.emplace_back("title", GetText().toUtf8());
826  pNotifier->notifyWindow(GetLOKWindowId(), IsVisible()? OUString("show"): OUString("hide"), aPayload);
827  }
828  }
829 }
830 
832 {
833  SystemWindow::DataChanged( rDCEvt );
834 
835  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
836  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
837  {
839  Invalidate();
840  }
841 }
842 
844 {
845  VclPtr<vcl::Window> xWindow = this;
847  if ( xWindow->isDisposed() )
848  return false;
849 
850  if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() && !IsInExecute() )
851  return false;
852 
853  // If there's a cancel button with a custom handler, then always give it a chance to
854  // handle Dialog::Close
855  PushButton* pCustomCancelButton;
856  PushButton* pCancelButton = dynamic_cast<PushButton*>(get_widget_for_response(RET_CANCEL));
857  if (!mbInClose && pCancelButton && pCancelButton->GetClickHdl().IsSet())
858  pCustomCancelButton = pCancelButton;
859  else
860  pCustomCancelButton = nullptr;
861 
862  mbInClose = true;
863 
864  if (pCustomCancelButton)
865  {
866  pCustomCancelButton->Click();
867  if (xWindow->isDisposed())
868  return true;
869  mbInClose = false;
870  return false;
871  }
872 
873  if ( !(GetStyle() & WB_CLOSEABLE) )
874  {
875  bool bRet = true;
876  PushButton* pButton = ImplGetCancelButton( this );
877  if ( pButton )
878  pButton->Click();
879  else
880  {
881  pButton = ImplGetOKButton( this );
882  if ( pButton )
883  pButton->Click();
884  else
885  bRet = false;
886  }
887  if ( xWindow->isDisposed() )
888  return true;
889  return bRet;
890  }
891 
892  if (IsInExecute() || mpDialogImpl->maEndCtx.isSet())
893  {
894  EndDialog();
895  mbInClose = false;
896  return true;
897  }
898  else
899  {
900  mbInClose = false;
901  return SystemWindow::Close();
902  }
903 }
904 
906 {
908 
909  if (IsInExecute() || mpDialogImpl->maEndCtx.isSet())
910  {
911 #ifdef DBG_UTIL
912  SAL_WARN( "vcl", "Dialog::StartExecuteModal() is called in Dialog::StartExecuteModal(): "
913  << ImplGetDialogText(this) );
914 #endif
915  return false;
916  }
917 
918  ImplSVData* pSVData = ImplGetSVData();
919 
920  const bool bKitActive = comphelper::LibreOfficeKit::isActive();
921 
922  const bool bModal = GetType() != WindowType::MODELESSDIALOG;
923 
924  if (bModal)
925  {
926  if (bKitActive && !GetLOKNotifier())
927  SetLOKNotifier(mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr));
928 
930  {
932  break;
934  if (bModal && GetLOKNotifier())
935  {
936  // check if there's already some dialog being ::Execute()d
937  const bool bDialogExecuting = std::any_of(pSVData->mpWinData->mpExecuteDialogs.begin(),
938  pSVData->mpWinData->mpExecuteDialogs.end(),
939  [](const Dialog* pDialog) {
940  return pDialog->IsInSyncExecute();
941  });
942  if (!(bDialogExecuting && IsInSyncExecute()))
943  break;
944  else
945  SAL_WARN("lok.dialog", "Dialog \"" << ImplGetDialogText(this) << "\" is being synchronously executed over an existing synchronously executing dialog.");
946  }
947 
948  SAL_INFO(
949  "vcl",
950  "Dialog \"" << ImplGetDialogText(this)
951  << "\"cancelled in silent mode");
952  return false;
953 
955  return false;
956 
957  default: // default cannot happen
959  std::abort();
960  }
961 
962 #ifdef DBG_UTIL
963  vcl::Window* pParent = GetParent();
964  if ( pParent )
965  {
966  pParent = pParent->ImplGetFirstOverlapWindow();
967  if (pParent)
968  {
969  SAL_WARN_IF( !pParent->IsReallyVisible(), "vcl",
970  "Dialog::StartExecuteModal() - Parent not visible" );
971  SAL_WARN_IF( !pParent->IsInputEnabled(), "vcl",
972  "Dialog::StartExecuteModal() - Parent input disabled, use another parent to ensure modality!" );
973  SAL_WARN_IF( pParent->IsInModalMode(), "vcl",
974  "Dialog::StartExecuteModal() - Parent already modally disabled, use another parent to ensure modality!" );
975  }
976  }
977 #endif
978 
979  // link all dialogs which are being executed
980  pSVData->mpWinData->mpExecuteDialogs.push_back(this);
981 
982  // stop capturing, in order to have control over the dialog
983  if (pSVData->mpWinData->mpTrackWin)
985  if (pSVData->mpWinData->mpCaptureWin)
986  pSVData->mpWinData->mpCaptureWin->ReleaseMouse();
987  EnableInput();
988  }
989 
990  mbInExecute = true;
991  // no real modality in LibreOfficeKit
992  if (!bKitActive && bModal)
993  SetModalInputMode(true);
994 
995  // FIXME: no layouting, workaround some clipping issues
997 
998  css::uno::Reference< css::uno::XComponentContext > xContext(
1000  bool bForceFocusAndToFront(officecfg::Office::Common::View::NewDocumentHandling::ForceFocusAndToFront::get(xContext));
1001  ShowFlags showFlags = bForceFocusAndToFront ? ShowFlags::ForegroundTask : ShowFlags::NONE;
1002  Show(true, showFlags);
1003 
1004  if (bModal)
1005  pSVData->maAppData.mnModalMode++;
1006 
1007  css::uno::Reference<css::frame::XGlobalEventBroadcaster> xEventBroadcaster(
1008  css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_SET_THROW);
1009  css::document::DocumentEvent aObject;
1010  aObject.EventName = "DialogExecute";
1011  xEventBroadcaster->documentEventOccured(aObject);
1012  if (bModal)
1013  UITestLogger::getInstance().log(OUStringConcatenation("Open Modal " + get_id()));
1014  else
1015  UITestLogger::getInstance().log(OUStringConcatenation("Open Modeless " + get_id()));
1016 
1017  bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling;
1018  if (comphelper::LibreOfficeKit::isActive() && bTunnelingEnabled)
1019  {
1020  if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
1021  {
1022  // Dialog boxes don't get the Resize call and they
1023  // can have invalid size at 'created' message above.
1024  // If there is no difference, the client should detect it and ignore us,
1025  // otherwise, this should make sure that the window has the correct size.
1026  std::vector<vcl::LOKPayloadItem> aItems;
1027  aItems.emplace_back("size", GetSizePixel().toString());
1028  pNotifier->notifyWindow(GetLOKWindowId(), "size_changed", aItems);
1029  }
1030  }
1031 
1032  return true;
1033 }
1034 
1036 {
1037  ImplSVData* pSVData = ImplGetSVData();
1038  pSVData->maAppData.mnModalMode--;
1039 }
1040 
1042 {
1043  VclPtr<vcl::Window> xWindow = this;
1044 
1045  mbInSyncExecute = true;
1046  comphelper::ScopeGuard aGuard([&]() {
1047  mbInSyncExecute = false;
1048  });
1049 
1050  if ( !ImplStartExecute() )
1051  return 0;
1052 
1053  // Yield util EndDialog is called or dialog gets destroyed
1054  // (the latter should not happen, but better safe than sorry
1055  while ( !xWindow->isDisposed() && mbInExecute && !Application::IsQuit() )
1057 
1059 #ifdef DBG_UTIL
1060  assert (!mpDialogParent || !mpDialogParent->isDisposed());
1061 #endif
1062  if ( !xWindow->isDisposed() )
1063  xWindow.clear();
1064  else
1065  {
1066  OSL_FAIL( "Dialog::Execute() - Dialog destroyed in Execute()" );
1067  }
1068 
1069  assert(mpDialogImpl);
1070 
1071  if (mpDialogImpl)
1072  {
1073  tools::Long nRet = mpDialogImpl->mnResult;
1074  mpDialogImpl->mnResult = -1;
1075 
1076  return static_cast<short>(nRet);
1077  }
1078  else
1079  {
1080  SAL_WARN( "vcl", "Dialog::Execute() : missing mpDialogImpl " );
1081  return 0;
1082  }
1083 }
1084 
1085 // virtual
1087 {
1088  const bool bModal = GetType() != WindowType::MODELESSDIALOG;
1089  if (!ImplStartExecute())
1090  {
1091  rCtx.mxOwner.disposeAndClear();
1092  rCtx.mxOwnerDialogController.reset();
1093  rCtx.mxOwnerSelf.reset();
1094  return false;
1095  }
1096 
1097  mpDialogImpl->maEndCtx = rCtx;
1098  mpDialogImpl->mbStartedModal = bModal;
1099 
1100  return true;
1101 }
1102 
1104 {
1105  ImplSVData* pSVData = ImplGetSVData();
1106  auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
1107 
1108  // remove dialog from the list of dialogs which are being executed
1109  rExecuteDialogs.erase(std::remove_if(rExecuteDialogs.begin(), rExecuteDialogs.end(), [this](VclPtr<Dialog>& dialog){ return dialog.get() == this; }), rExecuteDialogs.end());
1110 }
1111 
1113 {
1114  if (!mbInExecute || isDisposed())
1115  return;
1116 
1117  const bool bModal = GetType() != WindowType::MODELESSDIALOG;
1118 
1119  Hide();
1120 
1122  {
1123  if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
1124  {
1125  pNotifier->notifyWindow(GetLOKWindowId(), "close");
1127  }
1128  }
1129 
1130  if (bModal)
1131  {
1132  SetModalInputMode(false);
1133 
1135 
1136  // set focus to previous modal dialog if it is modal for
1137  // the same frame parent (or NULL)
1138  ImplSVData* pSVData = ImplGetSVData();
1139  if (!pSVData->mpWinData->mpExecuteDialogs.empty())
1140  {
1141  VclPtr<Dialog> pPrevious = pSVData->mpWinData->mpExecuteDialogs.back();
1142 
1143  vcl::Window* pFrameParent = ImplGetFrameWindow()->ImplGetParent();
1144  vcl::Window* pPrevFrameParent = pPrevious->ImplGetFrameWindow()? pPrevious->ImplGetFrameWindow()->ImplGetParent(): nullptr;
1145  if( ( !pFrameParent && !pPrevFrameParent ) ||
1146  ( pFrameParent && pPrevFrameParent && pFrameParent->ImplGetFrame() == pPrevFrameParent->ImplGetFrame() )
1147  )
1148  {
1149  pPrevious->GrabFocus();
1150  }
1151  }
1152  }
1153 
1154  mpDialogImpl->mnResult = nResult;
1155 
1156  if ( mpDialogImpl->mbStartedModal )
1158 
1159  if ( mpDialogImpl && mpDialogImpl->maEndCtx.isSet() )
1160  {
1161  auto fn = std::move(mpDialogImpl->maEndCtx.maEndDialogFn);
1162  // std::move leaves maEndDialogFn in a valid state with unspecified
1163  // value. For the SwSyncBtnDlg case gcc and msvc left maEndDialogFn
1164  // unset, but clang left maEndDialogFn at its original value, keeping
1165  // an extra reference to the DialogController in its lambda giving
1166  // an inconsistent lifecycle for the dialog. Force it to be unset.
1167  mpDialogImpl->maEndCtx.maEndDialogFn = nullptr;
1168  fn(nResult);
1169  }
1170 
1171  if ( mpDialogImpl && mpDialogImpl->mbStartedModal )
1172  {
1173  mpDialogImpl->mbStartedModal = false;
1174  mpDialogImpl->mnResult = -1;
1175  }
1176  mbInExecute = false;
1177 
1178  if ( mpDialogImpl )
1179  {
1180  // Destroy ourselves (if we have a context with VclPtr owner)
1181  std::shared_ptr<weld::DialogController> xOwnerDialogController = std::move(mpDialogImpl->maEndCtx.mxOwnerDialogController);
1182  std::shared_ptr<weld::Dialog> xOwnerSelf = std::move(mpDialogImpl->maEndCtx.mxOwnerSelf);
1183  mpDialogImpl->maEndCtx.mxOwner.disposeAndClear();
1184  xOwnerDialogController.reset();
1185  xOwnerSelf.reset();
1186  }
1187 }
1188 
1189 namespace vcl
1190 {
1191  void EndAllDialogs( vcl::Window const * pParent )
1192  {
1193  ImplSVData* pSVData = ImplGetSVData();
1194  auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
1195 
1196  for (auto it = rExecuteDialogs.rbegin(); it != rExecuteDialogs.rend(); ++it)
1197  {
1198  if (!pParent || pParent->IsWindowOrChild(*it, true))
1199  {
1200  (*it)->EndDialog();
1201  (*it)->PostUserEvent(Link<void*, void>());
1202  }
1203  }
1204  }
1205 
1207  {
1208  if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow))
1209  {
1210  pDialog->EnableInput();
1211  }
1212  }
1213 
1215  {
1216  if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow))
1217  pDialog->Close();
1218  else if (FloatingWindow* pFloatWin = dynamic_cast<FloatingWindow*>(pWindow))
1220  }
1221 }
1222 
1223 void Dialog::SetModalInputMode( bool bModal )
1224 {
1225  if ( bModal == mbModalMode )
1226  return;
1227 
1228  ImplGetFrame()->SetModal(bModal);
1229 
1230  if (GetParent())
1231  {
1232  SalFrame* pFrame = GetParent()->ImplGetFrame();
1233  pFrame->NotifyModalHierarchy(bModal);
1234  }
1235 
1236  ImplSetModalInputMode(bModal);
1237 }
1238 
1240 {
1241  if ( bModal == mbModalMode )
1242  return;
1243 
1244  // previously Execute()'d dialog - the one below the top-most one
1245  VclPtr<Dialog> pPrevious;
1246  ImplSVData* pSVData = ImplGetSVData();
1247  auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
1248  if (rExecuteDialogs.size() > 1)
1249  pPrevious = rExecuteDialogs[rExecuteDialogs.size() - 2];
1250 
1251  mbModalMode = bModal;
1252  if ( bModal )
1253  {
1254  // Disable the prev Modal Dialog, because our dialog must close at first,
1255  // before the other dialog can be closed (because the other dialog
1256  // is on stack since our dialog returns)
1257  if (pPrevious && !pPrevious->IsWindowOrChild(this, true))
1258  pPrevious->EnableInput(false, this);
1259 
1260  // determine next overlap dialog parent
1261  vcl::Window* pParent = GetParent();
1262  if ( pParent )
1263  {
1264  // #103716# dialogs should always be modal to the whole frame window
1265  // #115933# disable the whole frame hierarchy, useful if our parent
1266  // is a modeless dialog
1267  mpDialogParent = pParent->mpWindowImpl->mpFrameWindow;
1269  }
1270  }
1271  else
1272  {
1273  if ( mpDialogParent )
1274  {
1275  // #115933# re-enable the whole frame hierarchy again (see above)
1276  // note that code in getfocus assures that we do not accidentally enable
1277  // windows that were disabled before
1279  }
1280 
1281  // Enable the prev Modal Dialog
1282  if (pPrevious && !pPrevious->IsWindowOrChild(this, true))
1283  {
1284  pPrevious->EnableInput(true, this);
1285 
1286  // ensure continued modality of prev dialog
1287  // do not change modality counter
1288 
1289  // #i119994# need find the last modal dialog before reactive it
1290  if (pPrevious->IsModalInputMode() || !pPrevious->IsWindowOrChild(this, true))
1291  {
1292  pPrevious->ImplSetModalInputMode(false);
1293  pPrevious->ImplSetModalInputMode(true);
1294  }
1295  }
1296  }
1297 }
1298 
1300 {
1301  vcl::Window* pFocusControl = nullptr;
1302  vcl::Window* pFirstOverlapWindow = ImplGetFirstOverlapWindow();
1303 
1304  // find focus control, even if the dialog has focus
1305  if (!HasFocus() && pFirstOverlapWindow && pFirstOverlapWindow->mpWindowImpl)
1306  {
1307  // prefer a child window which had focus before
1308  pFocusControl = ImplGetFirstOverlapWindow()->mpWindowImpl->mpLastFocusWindow;
1309  // find the control out of the dialog control
1310  if ( pFocusControl )
1311  pFocusControl = ImplFindDlgCtrlWindow( pFocusControl );
1312  }
1313  // no control had the focus before or the control is not
1314  // part of the tab-control, now give focus to the
1315  // first control in the tab-control
1316  if ( !pFocusControl ||
1317  !(pFocusControl->GetStyle() & WB_TABSTOP) ||
1318  !isVisibleInLayout(pFocusControl) ||
1319  !isEnabledInLayout(pFocusControl) || !pFocusControl->IsInputEnabled() )
1320  {
1321  pFocusControl = ImplGetDlgWindow( 0, GetDlgWindowType::First );
1322  }
1323 
1324  return pFocusControl;
1325 }
1326 
1328 {
1329  vcl::Window* pFocusControl = GetFirstControlForFocus();
1330  if ( pFocusControl )
1331  pFocusControl->ImplControlFocus( GetFocusFlags::Init );
1332 }
1333 
1334 void Dialog::GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
1335 {
1336  ScopedVclPtrInstance<ImplBorderWindow> aImplWin( static_cast<vcl::Window*>(const_cast<Dialog *>(this)), WB_BORDER|WB_STDWORK, BorderWindowStyle::Overlap );
1337  aImplWin->GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder );
1338 }
1339 
1340 void Dialog::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags )
1341 {
1342  Point aPos = pDev->LogicToPixel( rPos );
1343  Size aSize = GetSizePixel();
1344 
1345  Wallpaper aWallpaper = GetBackground();
1346  if ( !aWallpaper.IsBitmap() )
1347  ImplInitSettings();
1348 
1349  pDev->Push();
1350  pDev->SetMapMode();
1351  pDev->SetLineColor();
1352 
1353  if ( aWallpaper.IsBitmap() )
1354  pDev->DrawBitmapEx( aPos, aSize, aWallpaper.GetBitmap() );
1355  else
1356  {
1357  pDev->SetFillColor( aWallpaper.GetColor() );
1358  pDev->DrawRect( tools::Rectangle( aPos, aSize ) );
1359  }
1360 
1361  if (!( GetStyle() & WB_NOBORDER ))
1362  {
1364  aImplWin->SetText( GetText() );
1365  aImplWin->setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
1366  aImplWin->SetDisplayActive( true );
1367  aImplWin->InitView();
1368 
1369  aImplWin->Draw( pDev, aPos );
1370  }
1371 
1372  pDev->Pop();
1373 }
1374 
1376 {
1377  if (IsInClose())
1378  return;
1379  SystemWindow::queue_resize(eReason);
1380 }
1381 
1383 {
1385 
1387  return;
1388 
1389  bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling;
1390  const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier();
1391  if (pNotifier && bTunnelingEnabled)
1392  {
1393  std::vector<vcl::LOKPayloadItem> aItems;
1394  aItems.emplace_back("size", GetSizePixel().toString());
1395  pNotifier->notifyWindow(GetLOKWindowId(), "size_changed", aItems);
1396  }
1397 }
1398 
1399 bool Dialog::set_property(const OString &rKey, const OUString &rValue)
1400 {
1401  if (rKey == "border-width")
1402  set_border_width(rValue.toInt32());
1403  else
1404  return SystemWindow::set_property(rKey, rValue);
1405  return true;
1406 }
1407 
1409 {
1410  return DialogUIObject::create;
1411 }
1412 
1413 IMPL_LINK(Dialog, ResponseHdl, Button*, pButton, void)
1414 {
1415  auto aFind = mpDialogImpl->maResponses.find(pButton);
1416  if (aFind == mpDialogImpl->maResponses.end())
1417  return;
1418  short nResponse = aFind->second;
1419  if (nResponse == RET_HELP)
1420  {
1422  if (!pFocusWin || comphelper::LibreOfficeKit::isActive())
1423  pFocusWin = pButton;
1425  pFocusWin->RequestHelp(aEvt);
1426  return;
1427  }
1428  EndDialog(nResponse);
1429 }
1430 
1431 void Dialog::add_button(PushButton* pButton, int response, bool bTransferOwnership)
1432 {
1433  if (bTransferOwnership)
1434  mpDialogImpl->maOwnedButtons.push_back(pButton);
1435  mpDialogImpl->maResponses[pButton] = response;
1436  switch (pButton->GetType())
1437  {
1438  case WindowType::PUSHBUTTON:
1439  {
1440  if (!pButton->GetClickHdl().IsSet())
1441  pButton->SetClickHdl(LINK(this, Dialog, ResponseHdl));
1442  break;
1443  }
1444  //insist that the response ids match the default actions for those
1445  //widgets, and leave their default handlers in place
1446  case WindowType::OKBUTTON:
1447  assert(mpDialogImpl->get_response(pButton) == RET_OK);
1448  break;
1449  case WindowType::CANCELBUTTON:
1450  assert(mpDialogImpl->get_response(pButton) == RET_CANCEL || mpDialogImpl->get_response(pButton) == RET_CLOSE);
1451  break;
1452  case WindowType::HELPBUTTON:
1453  assert(mpDialogImpl->get_response(pButton) == RET_HELP);
1454  break;
1455  default:
1456  SAL_WARN("vcl.layout", "The type of widget " <<
1457  pButton->GetHelpId() << " is currently not handled");
1458  break;
1459  }
1460 }
1461 
1463 {
1464  //copy explicit responses
1465  std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses);
1466 
1467  if (mpActionArea)
1468  {
1469  //add implicit responses
1471  pChild = pChild->GetWindow(GetWindowType::Next))
1472  {
1473  if (aResponses.find(pChild) != aResponses.end())
1474  continue;
1475  switch (pChild->GetType())
1476  {
1477  case WindowType::OKBUTTON:
1478  aResponses[pChild] = RET_OK;
1479  break;
1480  case WindowType::CANCELBUTTON:
1481  aResponses[pChild] = RET_CANCEL;
1482  break;
1483  case WindowType::HELPBUTTON:
1484  aResponses[pChild] = RET_HELP;
1485  break;
1486  default:
1487  break;
1488  }
1489  }
1490  }
1491 
1492  for (const auto& a : aResponses)
1493  {
1494  if (a.second == response)
1495  return a.first;
1496  }
1497 
1498  return nullptr;
1499 }
1500 
1502 {
1503  //copy explicit responses
1504  std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses);
1505 
1506  if (mpActionArea)
1507  {
1508  //add implicit responses
1510  pChild = pChild->GetWindow(GetWindowType::Next))
1511  {
1512  if (aResponses.find(pChild) != aResponses.end())
1513  continue;
1514  switch (pChild->GetType())
1515  {
1516  case WindowType::OKBUTTON:
1517  aResponses[pChild] = RET_OK;
1518  break;
1519  case WindowType::CANCELBUTTON:
1520  aResponses[pChild] = RET_CANCEL;
1521  break;
1522  case WindowType::HELPBUTTON:
1523  aResponses[pChild] = RET_HELP;
1524  break;
1525  default:
1526  break;
1527  }
1528  }
1529  }
1530 
1531  for (const auto& a : aResponses)
1532  {
1533  if (a.first->GetStyle() & WB_DEFBUTTON)
1534  {
1535  return a.second;
1536  }
1537  }
1538  return RET_CANCEL;
1539 }
1540 
1542 {
1543  //copy explicit responses
1544  std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses);
1545 
1546  if (mpActionArea)
1547  {
1548  //add implicit responses
1550  pChild = pChild->GetWindow(GetWindowType::Next))
1551  {
1552  if (aResponses.find(pChild) != aResponses.end())
1553  continue;
1554  switch (pChild->GetType())
1555  {
1556  case WindowType::OKBUTTON:
1557  aResponses[pChild] = RET_OK;
1558  break;
1559  case WindowType::CANCELBUTTON:
1560  aResponses[pChild] = RET_CANCEL;
1561  break;
1562  case WindowType::HELPBUTTON:
1563  aResponses[pChild] = RET_HELP;
1564  break;
1565  default:
1566  break;
1567  }
1568  }
1569  }
1570 
1571  for (auto& a : aResponses)
1572  {
1573  if (a.second == response)
1574  {
1575  a.first->SetStyle(a.first->GetStyle() | WB_DEFBUTTON);
1576  a.first->GrabFocus();
1577  }
1578  else
1579  {
1580  a.first->SetStyle(a.first->GetStyle() & ~WB_DEFBUTTON);
1581  }
1582  }
1583 }
1584 
1586 {
1587 }
1588 
1590 {
1591  if (!m_pUIBuilder)
1592  return;
1593  m_pUIBuilder->setDeferredProperties();
1594 }
1595 
1597 {
1598 }
1599 
1601 {
1602  if (GetType() == WindowType::MODELESSDIALOG)
1603  {
1604  css::uno::Reference< css::uno::XComponentContext > xContext(
1606  css::uno::Reference<css::frame::XGlobalEventBroadcaster> xEventBroadcaster(css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_SET_THROW);
1607  css::document::DocumentEvent aObject;
1608  aObject.EventName = "ModelessDialogVisible";
1609  xEventBroadcaster->documentEventOccured(aObject);
1610  }
1612 }
1613 
1614 void Dialog::Command(const CommandEvent& rCEvt)
1615 {
1616  if (mpDialogImpl && mpDialogImpl->m_aPopupMenuHdl.Call(rCEvt))
1617  return;
1618  SystemWindow::Command(rCEvt);
1619 }
1620 
1622 {
1623  std::stack<std::vector<VclPtr<vcl::Window>>> m_aBusyStack;
1624 };
1625 
1627  : m_xImpl(std::make_unique<TopLevelWindowLockerImpl>())
1628 {
1629 }
1630 
1632 {
1633  // lock any toplevel windows from being closed until busy is over
1634  std::vector<VclPtr<vcl::Window>> aTopLevels;
1636  while (pTopWin)
1637  {
1638  vcl::Window* pCandidate = pTopWin;
1639  if (pCandidate->GetType() == WindowType::BORDERWINDOW)
1640  pCandidate = pCandidate->GetWindow(GetWindowType::FirstChild);
1641  // tdf#125266 ignore HelpTextWindows
1642  if (pCandidate &&
1643  pCandidate->GetType() != WindowType::HELPTEXTWINDOW &&
1644  pCandidate->GetType() != WindowType::FLOATINGWINDOW &&
1645  pCandidate->GetFrameWeld() != pIgnore)
1646  {
1647  aTopLevels.push_back(pCandidate);
1648  }
1649  pTopWin = Application::GetNextTopLevelWindow(pTopWin);
1650  }
1651  for (auto& a : aTopLevels)
1652  {
1653  a->IncModalCount();
1654  a->ImplGetFrame()->NotifyModalHierarchy(true);
1655  }
1656  m_xImpl->m_aBusyStack.push(aTopLevels);
1657 }
1658 
1660 {
1661  // unlock locked toplevel windows from being closed now busy is over
1662  for (auto& a : m_xImpl->m_aBusyStack.top())
1663  {
1664  if (a->isDisposed())
1665  continue;
1666  a->DecModalCount();
1667  a->ImplGetFrame()->NotifyModalHierarchy(false);
1668  }
1669  m_xImpl->m_aBusyStack.pop();
1670 }
1671 
1673 {
1674  return !m_xImpl->m_aBusyStack.empty();
1675 }
1676 
1678 {
1679 }
1680 
1682 {
1683  SystemWindow::DumpAsPropertyTree(rJsonWriter);
1684  rJsonWriter.put("title", GetText());
1685  if (vcl::Window* pActionArea = get_action_area())
1686  {
1687  if (!pActionArea->IsVisible())
1688  rJsonWriter.put("collapsed", "true");
1689  }
1690 
1691  OUString sDialogId = OStringToOUString(GetHelpId(), RTL_TEXTENCODING_ASCII_US);
1692  sal_Int32 nStartPos = sDialogId.lastIndexOf('/');
1693  nStartPos = nStartPos >= 0 ? nStartPos + 1 : 0;
1694  rJsonWriter.put("dialogid", sDialogId.copy(nStartPos));
1695 
1696  {
1697  auto aResponses = rJsonWriter.startArray("responses");
1698  for (const auto& rResponse : mpDialogImpl->maResponses)
1699  {
1700  auto aResponse = rJsonWriter.startStruct();
1701  rJsonWriter.put("id", rResponse.first->get_id());
1702  rJsonWriter.put("response", rResponse.second);
1703  }
1704  }
1705 
1706  vcl::Window* pFocusControl = GetFirstControlForFocus();
1707  if (pFocusControl)
1708  rJsonWriter.put("init_focus_id", pFocusControl->get_id());
1709 }
1710 
1711 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE void ImplInitDialogData()
Definition: dialog.cxx:386
virtual void SetText(const OUString &rStr)
Definition: window.cxx:3026
do not automatically cancel dialogs
bool IsWindowOrChild(const vcl::Window *pWindow, bool bSystemWindow=false) const
Definition: stacking.cxx:1123
bool IsControlBackground() const
Definition: window2.cxx:1081
bool IsInputEnabled() const
Definition: window2.cxx:1121
void SetBackground()
Definition: window3.cxx:100
vcl::Window * ImplGetWindow() const
if this is a proxy return the client, otherwise itself
Definition: window2.cxx:824
Point GetPointerPosPixel()
Definition: mouse.cxx:557
void setDeferredProperties()
Definition: dialog.cxx:1589
vcl::LOKWindowId GetLOKWindowId() const
Definition: window.cxx:3253
OUString sMessage
std::stack< std::vector< VclPtr< vcl::Window > > > m_aBusyStack
Definition: dialog.cxx:1623
bool GetAutoMnemonic() const
WinBits const WB_SYSTEMWINDOW
bool isVisibleInLayout(const vcl::Window *pWindow)
Definition: layout.cxx:2878
vcl::Window * lastLogicalChildOfParent(const vcl::Window *pTopLevel)
Definition: dialog.cxx:196
WinBits const WB_NOLABEL
void log(std::u16string_view rString)
Definition: logger.cxx:181
void set_border_width(sal_Int32 nBorderWidth)
Definition: window2.cxx:1830
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: dialog.cxx:655
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: dialog.cxx:1375
void loadUI(vcl::Window *pParent, const OString &rID, const OUString &rUIXMLDescription, const css::uno::Reference< css::frame::XFrame > &rFrame=css::uno::Reference< css::frame::XFrame >())
Definition: syswin.cxx:88
virtual bool Close() override
Definition: dialog.cxx:843
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: syswin.cxx:174
virtual ~Dialog() override
Definition: dialog.cxx:615
void SetClickHdl(const Link< Button *, void > &rLink)
Definition: button.hxx:79
ScopedJsonWriterStruct startStruct()
virtual void ImplAdjustNWFSizes()
Definition: window3.cxx:28
void EndDialog(tools::Long nResult=RET_CANCEL)
Definition: dialog.cxx:1112
void DecModalCount()
Definition: window.cxx:3609
virtual void PixelInvalidate(const tools::Rectangle *pRectangle) override
Notification about some rectangle of the output device got invalidated.
Definition: dialog.cxx:399
WinBits const WB_NODIALOGCONTROL
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
Definition: bitmapex.cxx:33
silently cancel any dialogs (LOK case)
std::vector< VclPtr< PushButton > > maOwnedButtons
Definition: dialog.cxx:352
ImplSVAppData maAppData
Definition: svdata.hxx:396
long Long
void disposeAndClear()
Definition: vclptr.hxx:200
void SetDisplayActive(bool bActive)
Definition: brdwin.cxx:1859
Link< const CommandEvent &, bool > m_aPopupMenuHdl
Definition: dialog.cxx:357
const StyleSettings & GetStyleSettings() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:33
ScopedJsonWriterArray startArray(const char *)
SAL_DLLPRIVATE void disposeOwnedButtons()
Definition: dialog.cxx:380
bool IsInSyncExecute() const
Definition: dialog.hxx:126
sal_Int64 n
SAL_DLLPRIVATE vcl::Window * ImplGetBorderWindow() const
Definition: window2.cxx:864
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual Size GetSizePixel() const
Definition: window.cxx:2402
SAL_DLLPRIVATE vcl::Window * ImplGetFrameWindow() const
Definition: window2.cxx:895
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
void SetLOKNotifier(const vcl::ILibreOfficeKitNotifier *pNotifier, bool bParent=false)
Interface to register for dialog / window tunneling.
Definition: window.cxx:3178
sal_uInt16 GetCode() const
Definition: keycod.hxx:49
Link< void *, vcl::ILibreOfficeKitNotifier * > m_aInstallLOKNotifierHdl
Definition: dialog.cxx:358
DataChangedEventType GetType() const
Definition: event.hxx:362
const KeyEvent * GetKeyEvent() const
Definition: event.hxx:316
OUString CreateMnemonic(const OUString &rKey)
Definition: mnemonic.cxx:121
const Color & GetControlBackground() const
Definition: window2.cxx:1076
bool IsCreatedWithToolkit() const
Definition: window2.cxx:1231
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3004
bool mbStartedModal
Definition: dialog.cxx:355
VclPtr< VclButtonBox > mpActionArea
Definition: dialog.hxx:61
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
void SetMapMode()
Definition: map.cxx:594
std::shared_ptr< weld::DialogController > mxOwnerDialogController
Definition: abstdlg.hxx:61
virtual FactoryFunction GetUITestFactory() const override
Definition: dialog.cxx:1408
IMPL_LINK(Dialog, ResponseHdl, Button *, pButton, void)
Definition: dialog.cxx:1413
bool isBusy() const
Definition: dialog.cxx:1672
SAL_DLLPRIVATE vcl::Window * ImplFindDlgCtrlWindow(vcl::Window *pWindow)
Definition: dlgctrl.cxx:1099
StateChangedType
Definition: window.hxx:289
constexpr tools::Long Width() const
static UITestLogger & getInstance()
Definition: logger.cxx:611
weld::Window * GetFrameWeld() const
Definition: window2.cxx:842
A construction helper for ScopedVclPtr.
Definition: vclptr.hxx:407
sal_Int64 WinBits
void SetBackground()
Definition: background.cxx:27
static SAL_DLLPRIVATE vcl::Window * GetDefDialogParent()
Definition: svapp.cxx:1388
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: dialog.cxx:620
const OUString & get_id() const
Get the ID of the window.
Definition: window.cxx:3928
void GrabFocusToFirstControl()
Definition: dialog.cxx:1327
VclPtr< vcl::Window > GetParentWithLOKNotifier()
Find the nearest parent with LOK Notifier; can be itself if this Window has LOK notifier set...
Definition: window.cxx:3258
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3358
void EnableDialogInput(vcl::Window *pWindow)
Definition: dialog.cxx:1206
WinBits const WB_DEFBUTTON
static bool ImplIsMnemonicCtrl(vcl::Window *pWindow)
Definition: dialog.cxx:88
static VclButtonBox * getActionArea(Dialog const *pDialog)
Definition: dialog.cxx:255
static void Yield()
Process the next event.
Definition: svapp.cxx:530
std::shared_ptr< weld::Dialog > mxOwnerSelf
Definition: abstdlg.hxx:63
bool mbModalMode
Definition: dialog.hxx:58
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:271
static PushButton * ImplGetOKButton(Dialog const *pDialog)
Definition: dialog.cxx:299
vcl::Window * nextLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild)
Definition: dialog.cxx:132
MouseSettingsOptions GetOptions() const
void NotifyModalHierarchy(bool bModal)
Definition: salframe.hxx:302
void Hide()
Definition: window.hxx:884
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
void set_default_response(int nResponse)
Definition: dialog.cxx:1541
bool mbInSyncExecute
Definition: dialog.hxx:56
virtual void Click()
Definition: button.cxx:128
SystemTextColorFlags
void Pop()
Definition: stack.cxx:92
bool IsModalInputMode() const
Definition: dialog.hxx:150
virtual OUString GetText() const
Definition: window.cxx:3055
static SystemWindowFlags GetSystemWindowMode()
Get the system window mode of dialogs.
Definition: svapp.cxx:1471
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
void CloseTopLevel(vcl::Window *pWindow)
Definition: dialog.cxx:1214
static OString ImplGetDialogText(Dialog *pDialog)
Definition: dialog.cxx:71
SAL_DLLPRIVATE void ImplControlFocus(GetFocusFlags nFlags=GetFocusFlags::NONE)
Definition: dlgctrl.cxx:515
SAL_DLLPRIVATE Dialog(const Dialog &)=delete
MouseSettingsOptions
Definition: settings.hxx:52
void SetPointerPosPixel(const Point &rPos)
Definition: mouse.cxx:528
void IncModalCount()
Definition: window.cxx:3595
SAL_DLLPRIVATE vcl::Window * ImplGetDlgWindow(sal_uInt16 n, GetDlgWindowType nType, sal_uInt16 nStart=0, sal_uInt16 nEnd=0xFFFF, sal_uInt16 *pIndex=nullptr)
Definition: dlgctrl.cxx:204
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
bool isContainerWindow(const vcl::Window &rWindow)
Definition: layout.hxx:815
void ImplInitDialog(vcl::Window *pParent, WinBits nStyle, InitFlag eFlag=InitFlag::Default)
Definition: dialog.cxx:444
vcl::Window * firstLogicalChildOfParent(const vcl::Window *pTopLevel)
Definition: dialog.cxx:188
virtual bool Close()
Definition: syswin.cxx:260
void EnableInput(bool bEnable=true, bool bChild=true)
Definition: window.cxx:2493
const DialogStyle & GetDialogStyle() const
static vcl::Window * GetFirstTopLevelWindow()
Get the first top-level window of the application.
Definition: svapp.cxx:1074
static OUString GetUIRootDir()
Definition: dialog.cxx:556
WinBits const WB_DIALOGCONTROL
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
bool mbInClose
Definition: dialog.hxx:57
virtual void EndDialog(sal_Int32 nResult) override
void SetLineColor()
Definition: line.cxx:36
const OString & GetHelpId() const
Definition: window2.cxx:817
void ImplHideSplash()
Definition: dialog.cxx:125
VclPtr< VclBox > mpContentArea
Definition: dialog.hxx:62
void clear()
Definition: vclptr.hxx:190
std::vector< VclPtr< Dialog > > mpExecuteDialogs
Stack of dialogs that are Execute()'d - the last one is the top most one.
Definition: svdata.hxx:257
void SetLOKTunnelingState(bool bEnabled)
Definition: dialog.cxx:749
VclPtr< vcl::Window > mpCaptureWin
Definition: svdata.hxx:254
bool isEnabledInLayout(const vcl::Window *pWindow)
Definition: layout.cxx:2891
void SetActivateMode(ActivateModeFlags nMode)
Definition: window.cxx:2635
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: dialog.cxx:496
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: dialog.cxx:1399
static SAL_DLLPRIVATE vcl::Window * GetDefaultParent(WinBits nStyle)
Definition: dialog.cxx:407
silently cancel any dialogs
static void ImplMouseAutoPos(Dialog *pDialog)
Definition: dialog.cxx:328
sal_uInt16 mnModalMode
Definition: svdata.hxx:154
SAL_DLLPRIVATE VclPtr< vcl::Window > AddBorderWindow(vcl::Window *pParent, WinBits nBits)
Definition: dialog.cxx:432
bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx)
Commence execution of a modal dialog, disposes owner on failure.
Definition: dialog.cxx:1086
uno_Any a
VclPtr< vcl::Window > mpIntroWindow
Definition: svdata.hxx:404
void EndAllDialogs(vcl::Window const *pParent)
Definition: dialog.cxx:1191
VclAbstractDialog::AsyncContext maEndCtx
Definition: dialog.cxx:356
int get_default_response() const
Definition: dialog.cxx:1501
SystemWindowFlags
Definition: svapp.hxx:87
void SetInstallLOKNotifierHdl(const Link< void *, vcl::ILibreOfficeKitNotifier * > &rLink)
Definition: dialog.cxx:744
VclPtr< WorkWindow > mpAppWin
Definition: svdata.hxx:245
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
const Color & GetColor() const
Definition: wall.hxx:71
vcl::Window * get_widget_for_response(int nResponse)
Definition: dialog.cxx:1462
bool mbInExecute
Definition: dialog.hxx:55
void SetFillColor()
Definition: fill.cxx:29
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:175
const AllSettings & GetSettings() const
Definition: window3.cxx:129
float u
void add_button(PushButton *pButton, int nResponse, bool bTransferOwnership)
Definition: dialog.cxx:1431
static vcl::Window * getActionAreaButtonList(Dialog const *pDialog)
Definition: dialog.cxx:273
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:483
bool IsInModalMode() const
A window is in modal mode if one of its children or subchildren is a running modal window (a modal di...
Definition: window.cxx:3590
int content_area_border
Definition: settings.hxx:142
sal_Int32 w
SAL_DLLPRIVATE vcl::Window * ImplGetParent() const
Definition: window2.cxx:854
bool mbIsDeferredInit
Definition: syswin.hxx:113
std::unique_ptr< VclBuilder > m_pUIBuilder
Definition: syswin.hxx:86
std::map< VclPtr< vcl::Window >, short > maResponses
Definition: dialog.cxx:353
SAL_DLLPRIVATE bool ImplIsPushButton() const
Definition: window2.cxx:915
MouseNotifyEvent GetType() const
Definition: event.hxx:308
void Activate() override
Definition: dialog.cxx:1600
~DialogImpl()
Definition: dialog.cxx:373
tools::Long mnResult
Definition: dialog.cxx:354
bool IsInExecute() const
Definition: dialog.hxx:124
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1439
void SetPopupMenuHdl(const Link< const CommandEvent &, bool > &rLink)
Definition: dialog.cxx:739
short get_response(vcl::Window *pWindow) const
Definition: dialog.cxx:364
static void ImplEndExecuteModal()
Definition: dialog.cxx:1035
static PushButton * ImplGetDefaultButton(Dialog const *pDialog)
Definition: dialog.cxx:281
void GrabFocus()
Definition: window.cxx:2976
vcl::Window * GetParent() const
Definition: window2.cxx:1091
VclPtr< vcl::Window > mpTrackWin
Definition: svdata.hxx:259
static DialogCancelMode GetDialogCancelMode()
Gets the dialog cancel mode for headless environments.
Definition: svapp.cxx:1451
void put(const char *pPropName, const OUString &rPropValue)
WinBits const WB_NOBORDER
std::unique_ptr< TopLevelWindowLockerImpl > m_xImpl
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1035
short Execute()
Definition: dialog.cxx:1041
InitFlag
Definition: dialog.hxx:43
void disposeBuilder()
Definition: dialog.cxx:550
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:878
bool m_bLOKTunneling
Definition: dialog.cxx:359
void ReleaseMouse()
Definition: mouse.cxx:464
static PushButton * ImplGetCancelButton(Dialog const *pDialog)
Definition: dialog.cxx:313
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2666
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:938
WinBits const WB_SIZEABLE
WinBits const WB_STANDALONE
SAL_DLLPRIVATE vcl::Window * ImplGetFirstOverlapWindow()
Definition: window2.cxx:869
VclButtonBox * get_action_area()
Definition: dialog.hxx:118
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:275
SalFrame * ImplGetFrame() const
Definition: window2.cxx:837
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: dialog.cxx:1340
virtual void Resize() override
Definition: dialog.cxx:1382
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:114
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
static vcl::Window * GetFocusWindow()
Get the currently focused window.
Definition: svapp.cxx:1064
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: syswin.cxx:101
virtual void StateChanged(StateChangedType nStateChange) override
Definition: dialog.cxx:754
WinBits const WB_STDWORK
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: syswin.cxx:987
void Draw(OutputDevice *pDev, const Point &rPos)
Definition: brdwin.cxx:1622
IMPL_LINK_NOARG(Dialog, ImplAsyncCloseHdl, void *, void)
Definition: dialog.cxx:650
vcl::Window * prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild)
Definition: dialog.cxx:160
SAL_DLLPRIVATE bool ImplIsDefButton() const
Definition: button.cxx:1185
virtual void SetModal(bool)
Definition: salframe.hxx:259
static vcl::Window * GetNextTopLevelWindow(vcl::Window const *pWindow)
Get the next top level window.
Definition: svapp.cxx:1080
vcl::Window * GetFirstControlForFocus()
Definition: dialog.cxx:1299
WindowType
#define SAL_WARN_IF(condition, area, stream)
const BitmapEx & GetBitmap() const
Definition: wall.cxx:184
constexpr tools::Long Height() const
WinBits const WB_BORDER
bool ImplStartExecute()
Definition: dialog.cxx:905
constexpr sal_uInt16 KEY_ESCAPE
Definition: keycodes.hxx:120
virtual void Command(const CommandEvent &rCEvt) override
Definition: dialog.cxx:1614
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: brdwin.cxx:1954
ImplSVFrameData maFrameData
Definition: svdata.hxx:398
bool IsVisible() const
Definition: window2.cxx:1096
virtual OUString GetText() const override
Definition: syswin.cxx:1057
ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
Definition: event.cxx:334
#define SAL_INFO(area, stream)
int action_area_border
Definition: settings.hxx:144
void EnableChildTransparentMode(bool bEnable=true)
Definition: window2.cxx:1016
void set_content_area(VclBox *pBox)
Definition: dialog.cxx:602
cancel any dialogs by std::abort
SAL_DLLPRIVATE void ImplInitSettings()
Definition: dialog.cxx:516
VclPtr< VclReferenceBase > mxOwner
Definition: abstdlg.hxx:59
Reference< XComponentContext > getProcessComponentContext()
const MouseSettings & GetMouseSettings() const
void set_action_area(VclButtonBox *pBox)
Definition: dialog.cxx:591
vcl::Window * get_mnemonic_widget() const
Definition: fixed.hxx:76
InitFlag mnInitFlag
Definition: dialog.hxx:59
void set(reference_type *pBody)
Definition: vclptr.hxx:148
virtual void Activate()
Definition: window.cxx:1837
WinBits const WB_TABSTOP
Size GetOutputSizePixel() const
Definition: window3.cxx:89
VclPtr< vcl::Window > mpDialogParent
Definition: syswin.hxx:114
bool IsBitmap() const
Definition: wall.cxx:189
WindowType GetType() const
Definition: window2.cxx:968
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1940
ShowFlags
Definition: vclenum.hxx:389
const vcl::ILibreOfficeKitNotifier * GetLOKNotifier() const
Definition: window.cxx:3248
#define SAL_WARN(area, stream)
DialogImpl()
Definition: dialog.cxx:361
WinBits GetStyle() const
Definition: window2.cxx:947
void ReleaseLOKNotifier()
Indicate that LOK is not going to use this dialog any more.
Definition: window.cxx:3216
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
Definition: window3.cxx:74
WinBits const WB_CLOSEABLE
WinBits const WB_MOVEABLE
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: event.cxx:218
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1923
bool IsReallyVisible() const
Definition: window2.cxx:1101
virtual ~VclBuilderContainer()
Definition: dialog.cxx:1596
std::unique_ptr< DialogImpl > mpDialogImpl
Definition: dialog.hxx:53
SAL_DLLPRIVATE bool IsInClose() const
Definition: dialog.hxx:87
const Wallpaper & GetBackground() const
Definition: window3.cxx:63
bool HasFocus() const
Definition: window.cxx:2981
void ImplLOKNotifier(vcl::Window *pParent)
Find and set the LOK notifier according to the pParent.
Definition: dialog.cxx:532
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1869
void RegisterMnemonic(const OUString &rKey)
Definition: mnemonic.cxx:81
sal_Int32 h
virtual void doDeferredInit(WinBits nBits) override
Definition: dialog.cxx:565
bool isDisposed() const
virtual void Resize() override
Definition: syswin.cxx:999
bool isLayoutEnabled() const
Definition: syswin.cxx:1004
SAL_DLLPRIVATE void RemoveFromDlgList()
Definition: dialog.cxx:1103
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: dialog.cxx:831
void ImplSetModalInputMode(bool bModal)
Definition: dialog.cxx:1239
void SetModalInputMode(bool bModal)
Definition: dialog.cxx:1223
void DumpAsPropertyTree(tools::JsonWriter &rJsonWriter) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: dialog.cxx:1681
tools::Long mnMousePositioned
Definition: dialog.hxx:54
SAL_DLLPRIVATE void DoInitialLayout()
Definition: syswin.cxx:1088
void GetDrawWindowBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: dialog.cxx:1334
virtual void settingOptimalLayoutSize(Window *pBox) override
Definition: dialog.cxx:607
void GenerateAutoMnemonicsOnHierarchy(const vcl::Window *pWindow)
Definition: dialog.cxx:204
WinBits const WB_ALLOWMENUBAR
void incBusy(const weld::Widget *pIgnore)
Definition: dialog.cxx:1631
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
OUString toString(OptionInfo const *info)
ImplSVWinData * mpWinData
Definition: svdata.hxx:399
Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize)
Definition: dialog.cxx:705
static bool IsQuit()
Has Quit() been called?
Definition: svapp.cxx:580
const Link< Button *, void > & GetClickHdl() const
Definition: button.hxx:80
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2187
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo