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 )
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)
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)
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(OUString("Open Modal " + get_id()));
1014  else
1015  UITestLogger::getInstance().log(OUString("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  tools::Long nRet = mpDialogImpl->mnResult;
1070  mpDialogImpl->mnResult = -1;
1071 
1072  return static_cast<short>(nRet);
1073 }
1074 
1075 // virtual
1077 {
1078  const bool bModal = GetType() != WindowType::MODELESSDIALOG;
1079  if (!ImplStartExecute())
1080  {
1081  rCtx.mxOwner.disposeAndClear();
1082  rCtx.mxOwnerDialogController.reset();
1083  rCtx.mxOwnerSelf.reset();
1084  return false;
1085  }
1086 
1087  mpDialogImpl->maEndCtx = rCtx;
1088  mpDialogImpl->mbStartedModal = bModal;
1089 
1090  return true;
1091 }
1092 
1094 {
1095  ImplSVData* pSVData = ImplGetSVData();
1096  auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
1097 
1098  // remove dialog from the list of dialogs which are being executed
1099  rExecuteDialogs.erase(std::remove_if(rExecuteDialogs.begin(), rExecuteDialogs.end(), [this](VclPtr<Dialog>& dialog){ return dialog.get() == this; }), rExecuteDialogs.end());
1100 }
1101 
1103 {
1104  if (!mbInExecute || isDisposed())
1105  return;
1106 
1107  const bool bModal = GetType() != WindowType::MODELESSDIALOG;
1108 
1109  Hide();
1110 
1112  {
1113  if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
1114  {
1115  pNotifier->notifyWindow(GetLOKWindowId(), "close");
1117  }
1118  }
1119 
1120  if (bModal)
1121  {
1122  SetModalInputMode(false);
1123 
1125 
1126  // set focus to previous modal dialog if it is modal for
1127  // the same frame parent (or NULL)
1128  ImplSVData* pSVData = ImplGetSVData();
1129  if (!pSVData->mpWinData->mpExecuteDialogs.empty())
1130  {
1131  VclPtr<Dialog> pPrevious = pSVData->mpWinData->mpExecuteDialogs.back();
1132 
1133  vcl::Window* pFrameParent = ImplGetFrameWindow()->ImplGetParent();
1134  vcl::Window* pPrevFrameParent = pPrevious->ImplGetFrameWindow()? pPrevious->ImplGetFrameWindow()->ImplGetParent(): nullptr;
1135  if( ( !pFrameParent && !pPrevFrameParent ) ||
1136  ( pFrameParent && pPrevFrameParent && pFrameParent->ImplGetFrame() == pPrevFrameParent->ImplGetFrame() )
1137  )
1138  {
1139  pPrevious->GrabFocus();
1140  }
1141  }
1142  }
1143 
1144  mpDialogImpl->mnResult = nResult;
1145 
1146  if ( mpDialogImpl->mbStartedModal )
1148 
1149  if ( mpDialogImpl && mpDialogImpl->maEndCtx.isSet() )
1150  {
1151  auto fn = std::move(mpDialogImpl->maEndCtx.maEndDialogFn);
1152  // std::move leaves maEndDialogFn in a valid state with unspecified
1153  // value. For the SwSyncBtnDlg case gcc and msvc left maEndDialogFn
1154  // unset, but clang left maEndDialogFn at its original value, keeping
1155  // an extra reference to the DialogController in its lambda giving
1156  // an inconsistent lifecycle for the dialog. Force it to be unset.
1157  mpDialogImpl->maEndCtx.maEndDialogFn = nullptr;
1158  fn(nResult);
1159  }
1160 
1161  if ( mpDialogImpl && mpDialogImpl->mbStartedModal )
1162  {
1163  mpDialogImpl->mbStartedModal = false;
1164  mpDialogImpl->mnResult = -1;
1165  }
1166  mbInExecute = false;
1167 
1168  if ( mpDialogImpl )
1169  {
1170  // Destroy ourselves (if we have a context with VclPtr owner)
1171  std::shared_ptr<weld::DialogController> xOwnerDialogController = std::move(mpDialogImpl->maEndCtx.mxOwnerDialogController);
1172  std::shared_ptr<weld::Dialog> xOwnerSelf = std::move(mpDialogImpl->maEndCtx.mxOwnerSelf);
1173  mpDialogImpl->maEndCtx.mxOwner.disposeAndClear();
1174  xOwnerDialogController.reset();
1175  xOwnerSelf.reset();
1176  }
1177 }
1178 
1179 namespace vcl
1180 {
1181  void EndAllDialogs( vcl::Window const * pParent )
1182  {
1183  ImplSVData* pSVData = ImplGetSVData();
1184  auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
1185 
1186  for (auto it = rExecuteDialogs.rbegin(); it != rExecuteDialogs.rend(); ++it)
1187  {
1188  if (!pParent || pParent->IsWindowOrChild(*it, true))
1189  {
1190  (*it)->EndDialog();
1191  (*it)->PostUserEvent(Link<void*, void>());
1192  }
1193  }
1194  }
1195 
1197  {
1198  if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow))
1199  {
1200  pDialog->EnableInput();
1201  }
1202  }
1203 
1205  {
1206  if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow))
1207  pDialog->Close();
1208  else if (FloatingWindow* pFloatWin = dynamic_cast<FloatingWindow*>(pWindow))
1210  }
1211 }
1212 
1213 void Dialog::SetModalInputMode( bool bModal )
1214 {
1215  if ( bModal == mbModalMode )
1216  return;
1217 
1218  ImplGetFrame()->SetModal(bModal);
1219 
1220  if (GetParent())
1221  {
1222  SalFrame* pFrame = GetParent()->ImplGetFrame();
1223  pFrame->NotifyModalHierarchy(bModal);
1224  }
1225 
1226  ImplSetModalInputMode(bModal);
1227 }
1228 
1230 {
1231  if ( bModal == mbModalMode )
1232  return;
1233 
1234  // previously Execute()'d dialog - the one below the top-most one
1235  VclPtr<Dialog> pPrevious;
1236  ImplSVData* pSVData = ImplGetSVData();
1237  auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
1238  if (rExecuteDialogs.size() > 1)
1239  pPrevious = rExecuteDialogs[rExecuteDialogs.size() - 2];
1240 
1241  mbModalMode = bModal;
1242  if ( bModal )
1243  {
1244  // Disable the prev Modal Dialog, because our dialog must close at first,
1245  // before the other dialog can be closed (because the other dialog
1246  // is on stack since our dialog returns)
1247  if (pPrevious && !pPrevious->IsWindowOrChild(this, true))
1248  pPrevious->EnableInput(false, this);
1249 
1250  // determine next overlap dialog parent
1251  vcl::Window* pParent = GetParent();
1252  if ( pParent )
1253  {
1254  // #103716# dialogs should always be modal to the whole frame window
1255  // #115933# disable the whole frame hierarchy, useful if our parent
1256  // is a modeless dialog
1257  mpDialogParent = pParent->mpWindowImpl->mpFrameWindow;
1259  }
1260  }
1261  else
1262  {
1263  if ( mpDialogParent )
1264  {
1265  // #115933# re-enable the whole frame hierarchy again (see above)
1266  // note that code in getfocus assures that we do not accidentally enable
1267  // windows that were disabled before
1269  }
1270 
1271  // Enable the prev Modal Dialog
1272  if (pPrevious && !pPrevious->IsWindowOrChild(this, true))
1273  {
1274  pPrevious->EnableInput(true, this);
1275 
1276  // ensure continued modality of prev dialog
1277  // do not change modality counter
1278 
1279  // #i119994# need find the last modal dialog before reactive it
1280  if (pPrevious->IsModalInputMode() || !pPrevious->IsWindowOrChild(this, true))
1281  {
1282  pPrevious->ImplSetModalInputMode(false);
1283  pPrevious->ImplSetModalInputMode(true);
1284  }
1285  }
1286  }
1287 }
1288 
1290 {
1291  vcl::Window* pFocusControl = nullptr;
1292  vcl::Window* pFirstOverlapWindow = ImplGetFirstOverlapWindow();
1293 
1294  // find focus control, even if the dialog has focus
1295  if (!HasFocus() && pFirstOverlapWindow && pFirstOverlapWindow->mpWindowImpl)
1296  {
1297  // prefer a child window which had focus before
1298  pFocusControl = ImplGetFirstOverlapWindow()->mpWindowImpl->mpLastFocusWindow;
1299  // find the control out of the dialog control
1300  if ( pFocusControl )
1301  pFocusControl = ImplFindDlgCtrlWindow( pFocusControl );
1302  }
1303  // no control had the focus before or the control is not
1304  // part of the tab-control, now give focus to the
1305  // first control in the tab-control
1306  if ( !pFocusControl ||
1307  !(pFocusControl->GetStyle() & WB_TABSTOP) ||
1308  !isVisibleInLayout(pFocusControl) ||
1309  !isEnabledInLayout(pFocusControl) || !pFocusControl->IsInputEnabled() )
1310  {
1311  pFocusControl = ImplGetDlgWindow( 0, GetDlgWindowType::First );
1312  }
1313  if ( pFocusControl )
1314  pFocusControl->ImplControlFocus( GetFocusFlags::Init );
1315 }
1316 
1317 void Dialog::GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
1318 {
1319  ScopedVclPtrInstance<ImplBorderWindow> aImplWin( static_cast<vcl::Window*>(const_cast<Dialog *>(this)), WB_BORDER|WB_STDWORK, BorderWindowStyle::Overlap );
1320  aImplWin->GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder );
1321 }
1322 
1323 void Dialog::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags )
1324 {
1325  Point aPos = pDev->LogicToPixel( rPos );
1326  Size aSize = GetSizePixel();
1327 
1328  Wallpaper aWallpaper = GetBackground();
1329  if ( !aWallpaper.IsBitmap() )
1330  ImplInitSettings();
1331 
1332  pDev->Push();
1333  pDev->SetMapMode();
1334  pDev->SetLineColor();
1335 
1336  if ( aWallpaper.IsBitmap() )
1337  pDev->DrawBitmapEx( aPos, aSize, aWallpaper.GetBitmap() );
1338  else
1339  {
1340  pDev->SetFillColor( aWallpaper.GetColor() );
1341  pDev->DrawRect( tools::Rectangle( aPos, aSize ) );
1342  }
1343 
1344  if (!( GetStyle() & WB_NOBORDER ))
1345  {
1347  aImplWin->SetText( GetText() );
1348  aImplWin->setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
1349  aImplWin->SetDisplayActive( true );
1350  aImplWin->InitView();
1351 
1352  aImplWin->Draw( pDev, aPos );
1353  }
1354 
1355  pDev->Pop();
1356 }
1357 
1359 {
1360  if (IsInClose())
1361  return;
1362  SystemWindow::queue_resize(eReason);
1363 }
1364 
1366 {
1368 
1370  return;
1371 
1372  bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling;
1373  const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier();
1374  if (pNotifier && bTunnelingEnabled)
1375  {
1376  std::vector<vcl::LOKPayloadItem> aItems;
1377  aItems.emplace_back("size", GetSizePixel().toString());
1378  pNotifier->notifyWindow(GetLOKWindowId(), "size_changed", aItems);
1379  }
1380 }
1381 
1382 bool Dialog::set_property(const OString &rKey, const OUString &rValue)
1383 {
1384  if (rKey == "border-width")
1385  set_border_width(rValue.toInt32());
1386  else
1387  return SystemWindow::set_property(rKey, rValue);
1388  return true;
1389 }
1390 
1392 {
1393  return DialogUIObject::create;
1394 }
1395 
1396 IMPL_LINK(Dialog, ResponseHdl, Button*, pButton, void)
1397 {
1398  auto aFind = mpDialogImpl->maResponses.find(pButton);
1399  if (aFind == mpDialogImpl->maResponses.end())
1400  return;
1401  short nResponse = aFind->second;
1402  if (nResponse == RET_HELP)
1403  {
1405  if (!pFocusWin || comphelper::LibreOfficeKit::isActive())
1406  pFocusWin = pButton;
1408  pFocusWin->RequestHelp(aEvt);
1409  return;
1410  }
1411  EndDialog(nResponse);
1412 }
1413 
1414 void Dialog::add_button(PushButton* pButton, int response, bool bTransferOwnership)
1415 {
1416  if (bTransferOwnership)
1417  mpDialogImpl->maOwnedButtons.push_back(pButton);
1418  mpDialogImpl->maResponses[pButton] = response;
1419  switch (pButton->GetType())
1420  {
1421  case WindowType::PUSHBUTTON:
1422  {
1423  if (!pButton->GetClickHdl().IsSet())
1424  pButton->SetClickHdl(LINK(this, Dialog, ResponseHdl));
1425  break;
1426  }
1427  //insist that the response ids match the default actions for those
1428  //widgets, and leave their default handlers in place
1429  case WindowType::OKBUTTON:
1430  assert(mpDialogImpl->get_response(pButton) == RET_OK);
1431  break;
1432  case WindowType::CANCELBUTTON:
1433  assert(mpDialogImpl->get_response(pButton) == RET_CANCEL || mpDialogImpl->get_response(pButton) == RET_CLOSE);
1434  break;
1435  case WindowType::HELPBUTTON:
1436  assert(mpDialogImpl->get_response(pButton) == RET_HELP);
1437  break;
1438  default:
1439  SAL_WARN("vcl.layout", "The type of widget " <<
1440  pButton->GetHelpId() << " is currently not handled");
1441  break;
1442  }
1443 }
1444 
1446 {
1447  //copy explicit responses
1448  std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses);
1449 
1450  if (mpActionArea)
1451  {
1452  //add implicit responses
1454  pChild = pChild->GetWindow(GetWindowType::Next))
1455  {
1456  if (aResponses.find(pChild) != aResponses.end())
1457  continue;
1458  switch (pChild->GetType())
1459  {
1460  case WindowType::OKBUTTON:
1461  aResponses[pChild] = RET_OK;
1462  break;
1463  case WindowType::CANCELBUTTON:
1464  aResponses[pChild] = RET_CANCEL;
1465  break;
1466  case WindowType::HELPBUTTON:
1467  aResponses[pChild] = RET_HELP;
1468  break;
1469  default:
1470  break;
1471  }
1472  }
1473  }
1474 
1475  for (const auto& a : aResponses)
1476  {
1477  if (a.second == response)
1478  return a.first;
1479  }
1480 
1481  return nullptr;
1482 }
1483 
1485 {
1486  //copy explicit responses
1487  std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses);
1488 
1489  if (mpActionArea)
1490  {
1491  //add implicit responses
1493  pChild = pChild->GetWindow(GetWindowType::Next))
1494  {
1495  if (aResponses.find(pChild) != aResponses.end())
1496  continue;
1497  switch (pChild->GetType())
1498  {
1499  case WindowType::OKBUTTON:
1500  aResponses[pChild] = RET_OK;
1501  break;
1502  case WindowType::CANCELBUTTON:
1503  aResponses[pChild] = RET_CANCEL;
1504  break;
1505  case WindowType::HELPBUTTON:
1506  aResponses[pChild] = RET_HELP;
1507  break;
1508  default:
1509  break;
1510  }
1511  }
1512  }
1513 
1514  for (const auto& a : aResponses)
1515  {
1516  if (a.first->GetStyle() & WB_DEFBUTTON)
1517  {
1518  return a.second;
1519  }
1520  }
1521  return RET_CANCEL;
1522 }
1523 
1525 {
1526  //copy explicit responses
1527  std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses);
1528 
1529  if (mpActionArea)
1530  {
1531  //add implicit responses
1533  pChild = pChild->GetWindow(GetWindowType::Next))
1534  {
1535  if (aResponses.find(pChild) != aResponses.end())
1536  continue;
1537  switch (pChild->GetType())
1538  {
1539  case WindowType::OKBUTTON:
1540  aResponses[pChild] = RET_OK;
1541  break;
1542  case WindowType::CANCELBUTTON:
1543  aResponses[pChild] = RET_CANCEL;
1544  break;
1545  case WindowType::HELPBUTTON:
1546  aResponses[pChild] = RET_HELP;
1547  break;
1548  default:
1549  break;
1550  }
1551  }
1552  }
1553 
1554  for (auto& a : aResponses)
1555  {
1556  if (a.second == response)
1557  {
1558  a.first->SetStyle(a.first->GetStyle() | WB_DEFBUTTON);
1559  a.first->GrabFocus();
1560  }
1561  else
1562  {
1563  a.first->SetStyle(a.first->GetStyle() & ~WB_DEFBUTTON);
1564  }
1565  }
1566 }
1567 
1569 {
1570 }
1571 
1573 {
1574  if (!m_pUIBuilder)
1575  return;
1576  m_pUIBuilder->setDeferredProperties();
1577 }
1578 
1580 {
1581 }
1582 
1584 {
1585  if (GetType() == WindowType::MODELESSDIALOG)
1586  {
1587  css::uno::Reference< css::uno::XComponentContext > xContext(
1589  css::uno::Reference<css::frame::XGlobalEventBroadcaster> xEventBroadcaster(css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_SET_THROW);
1590  css::document::DocumentEvent aObject;
1591  aObject.EventName = "ModelessDialogVisible";
1592  xEventBroadcaster->documentEventOccured(aObject);
1593  }
1595 }
1596 
1597 void Dialog::Command(const CommandEvent& rCEvt)
1598 {
1599  if (mpDialogImpl && mpDialogImpl->m_aPopupMenuHdl.Call(rCEvt))
1600  return;
1601  SystemWindow::Command(rCEvt);
1602 }
1603 
1605 {
1606  std::stack<std::vector<VclPtr<vcl::Window>>> m_aBusyStack;
1607 };
1608 
1610  : m_xImpl(std::make_unique<TopLevelWindowLockerImpl>())
1611 {
1612 }
1613 
1615 {
1616  // lock any toplevel windows from being closed until busy is over
1617  std::vector<VclPtr<vcl::Window>> aTopLevels;
1619  while (pTopWin)
1620  {
1621  vcl::Window* pCandidate = pTopWin;
1622  if (pCandidate->GetType() == WindowType::BORDERWINDOW)
1623  pCandidate = pCandidate->GetWindow(GetWindowType::FirstChild);
1624  // tdf#125266 ignore HelpTextWindows
1625  if (pCandidate &&
1626  pCandidate->GetType() != WindowType::HELPTEXTWINDOW &&
1627  pCandidate->GetType() != WindowType::FLOATINGWINDOW &&
1628  pCandidate->GetFrameWeld() != pIgnore)
1629  {
1630  aTopLevels.push_back(pCandidate);
1631  }
1632  pTopWin = Application::GetNextTopLevelWindow(pTopWin);
1633  }
1634  for (auto& a : aTopLevels)
1635  {
1636  a->IncModalCount();
1637  a->ImplGetFrame()->NotifyModalHierarchy(true);
1638  }
1639  m_xImpl->m_aBusyStack.push(aTopLevels);
1640 }
1641 
1643 {
1644  // unlock locked toplevel windows from being closed now busy is over
1645  for (auto& a : m_xImpl->m_aBusyStack.top())
1646  {
1647  if (a->isDisposed())
1648  continue;
1649  a->DecModalCount();
1650  a->ImplGetFrame()->NotifyModalHierarchy(false);
1651  }
1652  m_xImpl->m_aBusyStack.pop();
1653 }
1654 
1656 {
1657  return !m_xImpl->m_aBusyStack.empty();
1658 }
1659 
1661 {
1662 }
1663 
1665 {
1666  SystemWindow::DumpAsPropertyTree(rJsonWriter);
1667  rJsonWriter.put("title", GetText());
1668  if (vcl::Window* pActionArea = get_action_area())
1669  {
1670  if (!pActionArea->IsVisible())
1671  rJsonWriter.put("collapsed", "true");
1672  }
1673 
1674  OUString sDialogId = OStringToOUString(GetHelpId(), RTL_TEXTENCODING_ASCII_US);
1675  sal_Int32 nStartPos = sDialogId.lastIndexOf('/');
1676  nStartPos = nStartPos >= 0 ? nStartPos + 1 : 0;
1677  rJsonWriter.put("dialogid", sDialogId.copy(nStartPos));
1678 
1679  {
1680  auto aResponses = rJsonWriter.startArray("responses");
1681  for (const auto& rResponse : mpDialogImpl->maResponses)
1682  {
1683  auto aResponse = rJsonWriter.startStruct();
1684  rJsonWriter.put("id", rResponse.first->get_id());
1685  rJsonWriter.put("response", rResponse.second);
1686  }
1687  }
1688 }
1689 
1690 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE void ImplInitDialogData()
Definition: dialog.cxx:386
virtual void SetText(const OUString &rStr)
Definition: window.cxx:3016
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:556
void setDeferredProperties()
Definition: dialog.cxx:1572
vcl::LOKWindowId GetLOKWindowId() const
Definition: window.cxx:3243
OUString sMessage
std::stack< std::vector< VclPtr< vcl::Window > > > m_aBusyStack
Definition: dialog.cxx:1606
bool GetAutoMnemonic() const
WinBits const WB_SYSTEMWINDOW
bool isVisibleInLayout(const vcl::Window *pWindow)
Definition: layout.cxx:2873
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:1358
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:1102
void DecModalCount()
Definition: window.cxx:3599
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)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: bitmapex.cxx:33
silently cancel any dialogs (LOK case)
std::vector< VclPtr< PushButton > > maOwnedButtons
Definition: dialog.cxx:352
ImplSVAppData maAppData
Definition: svdata.hxx:393
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
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:2392
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:3168
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:2994
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:592
std::shared_ptr< weld::DialogController > mxOwnerDialogController
Definition: abstdlg.hxx:61
virtual FactoryFunction GetUITestFactory() const override
Definition: dialog.cxx:1391
IMPL_LINK(Dialog, ResponseHdl, Button *, pButton, void)
Definition: dialog.cxx:1396
bool isBusy() const
Definition: dialog.cxx:1655
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:1382
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:3918
void GrabFocusToFirstControl()
Definition: dialog.cxx:1289
VclPtr< vcl::Window > GetParentWithLOKNotifier()
Find the nearest parent with LOK Notifier; can be itself if this Window has LOK notifier set...
Definition: window.cxx:3248
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3348
void EnableDialogInput(vcl::Window *pWindow)
Definition: dialog.cxx:1196
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:272
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:300
void Hide()
Definition: window.hxx:884
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
void set_default_response(int nResponse)
Definition: dialog.cxx:1524
bool mbInSyncExecute
Definition: dialog.hxx:56
virtual void Click()
Definition: button.cxx:128
SystemTextColorFlags
void Pop()
Definition: stack.cxx:93
bool IsModalInputMode() const
Definition: dialog.hxx:148
virtual OUString GetText() const
Definition: window.cxx:3045
static SystemWindowFlags GetSystemWindowMode()
Get the system window mode of dialogs.
Definition: svapp.cxx:1465
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
void CloseTopLevel(vcl::Window *pWindow)
Definition: dialog.cxx:1204
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:527
void IncModalCount()
Definition: window.cxx:3585
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:2483
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
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:254
void SetLOKTunnelingState(bool bEnabled)
Definition: dialog.cxx:749
VclPtr< vcl::Window > mpCaptureWin
Definition: svdata.hxx:251
bool isEnabledInLayout(const vcl::Window *pWindow)
Definition: layout.cxx:2886
void SetActivateMode(ActivateModeFlags nMode)
Definition: window.cxx:2625
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:1382
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:151
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:1076
uno_Any a
VclPtr< vcl::Window > mpIntroWindow
Definition: svdata.hxx:401
void EndAllDialogs(vcl::Window const *pParent)
Definition: dialog.cxx:1181
VclAbstractDialog::AsyncContext maEndCtx
Definition: dialog.cxx:356
int get_default_response() const
Definition: dialog.cxx:1484
SystemWindowFlags
Definition: svapp.hxx:87
void SetInstallLOKNotifierHdl(const Link< void *, vcl::ILibreOfficeKitNotifier * > &rLink)
Definition: dialog.cxx:744
VclPtr< WorkWindow > mpAppWin
Definition: svdata.hxx:242
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1164
const Color & GetColor() const
Definition: wall.hxx:71
vcl::Window * get_widget_for_response(int nResponse)
Definition: dialog.cxx:1445
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:168
const AllSettings & GetSettings() const
Definition: window3.cxx:129
float u
void add_button(PushButton *pButton, int nResponse, bool bTransferOwnership)
Definition: dialog.cxx:1414
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:3580
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:1583
~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:2966
vcl::Window * GetParent() const
Definition: window2.cxx:1091
VclPtr< vcl::Window > mpTrackWin
Definition: svdata.hxx:256
static DialogCancelMode GetDialogCancelMode()
Gets the dialog cancel mode for headless environments.
Definition: svapp.cxx:1445
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:876
bool m_bLOKTunneling
Definition: dialog.cxx:359
void ReleaseMouse()
Definition: mouse.cxx:463
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:2656
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:935
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:1323
virtual void Resize() override
Definition: dialog.cxx:1365
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
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:1182
virtual void SetModal(bool)
Definition: salframe.hxx:257
static vcl::Window * GetNextTopLevelWindow(vcl::Window const *pWindow)
Get the next top level window.
Definition: svapp.cxx:1080
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:1597
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: brdwin.cxx:1954
ImplSVFrameData maFrameData
Definition: svdata.hxx:395
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:1827
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:1930
ShowFlags
Definition: vclenum.hxx:389
const vcl::ILibreOfficeKitNotifier * GetLOKNotifier() const
Definition: window.cxx:3238
#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:3206
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:1913
bool IsReallyVisible() const
Definition: window2.cxx:1101
virtual ~VclBuilderContainer()
Definition: dialog.cxx:1579
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:2971
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: stack.cxx:34
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:1859
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:1093
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: dialog.cxx:831
void ImplSetModalInputMode(bool bModal)
Definition: dialog.cxx:1229
void SetModalInputMode(bool bModal)
Definition: dialog.cxx:1213
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:1664
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:1317
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:1614
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
OUString toString(OptionInfo const *info)
ImplSVWinData * mpWinData
Definition: svdata.hxx:396
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:2177
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo