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 <brdwin.hxx>
38 
39 #include <rtl/bootstrap.hxx>
40 #include <rtl/strbuf.hxx>
41 #include <sal/log.hxx>
42 
43 #include <vcl/abstdlg.hxx>
44 #include <vcl/accel.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 
204 void Accelerator::GenerateAutoMnemonicsOnHierarchy(const vcl::Window* pWindow)
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()->IsWindowOrChild(rDialogPtr, true) &&
422  rDialogPtr->IsReallyVisible() && rDialogPtr->IsEnabled() &&
423  rDialogPtr->IsInputEnabled() && !rDialogPtr->IsInModalMode(); });
424  if (it != rExecuteDialogs.rend())
425  pParent = it->get();
426  }
427 
428  return pParent;
429 }
430 
432 {
433  VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle, BorderWindowStyle::Frame );
434  ImplInit( pBorderWin, nStyle & ~WB_BORDER, nullptr );
435  pBorderWin->mpWindowImpl->mpClientWindow = this;
436  pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
437  mpWindowImpl->mpBorderWindow = pBorderWin;
438  mpWindowImpl->mpRealParent = pParent;
439 
440  return pBorderWin;
441 }
442 
443 void Dialog::ImplInitDialog( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag )
444 {
446 
447  if ( !(nStyle & WB_NODIALOGCONTROL) )
448  nStyle |= WB_DIALOGCONTROL;
449 
450  // Now, all Dialogs are per default system windows !!!
451  nStyle |= WB_SYSTEMWINDOW;
452 
453  if (InitFlag::NoParent == eFlag)
454  {
455  pParent = nullptr;
456  }
457  else if (!pParent) // parent is NULL: get the default Dialog parent
458  {
459  pParent = Dialog::GetDefaultParent(nStyle);
460  }
461 
462  if ( !pParent || (nStyle & WB_SYSTEMWINDOW) ||
463  (pParent->mpWindowImpl->mpFrameData->mbNeedSysWindow && !(nSysWinMode & SystemWindowFlags::NOAUTOMODE)) ||
464  (nSysWinMode & SystemWindowFlags::DIALOG) )
465  {
466  // create window with a small border ?
467  if ((nStyle & WB_ALLOWMENUBAR) || ((nStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE)) == WB_BORDER))
468  {
469  AddBorderWindow(pParent, nStyle);
470  }
471  else
472  {
473  mpWindowImpl->mbFrame = true;
474  mpWindowImpl->mbOverlapWin = true;
475  ImplInit( pParent, (nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_STANDALONE)) | WB_CLOSEABLE, nullptr );
476  // Now set all style bits
477  mpWindowImpl->mnStyle = nStyle;
478  }
479  }
480  else
481  {
482  VclPtrInstance<ImplBorderWindow> pBorderWin( pParent, nStyle, BorderWindowStyle::Overlap );
483  ImplInit( pBorderWin, nStyle & ~WB_BORDER, nullptr );
484  pBorderWin->mpWindowImpl->mpClientWindow = this;
485  pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
486  mpWindowImpl->mpBorderWindow = pBorderWin;
487  mpWindowImpl->mpRealParent = pParent;
488  }
489 
491 
493 }
494 
496 {
497  if (IsControlBackground())
498  {
499  // user override
501  }
503  {
504  // NWF background
505  mpWindowImpl->mnNativeBackground = ControlPart::BackgroundDialog;
507  }
508  else
509  {
510  // fallback to settings color
511  rRenderContext.SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
512  }
513 }
514 
516 {
517  // user override
518  if (IsControlBackground())
520  // NWF background
522  {
523  mpWindowImpl->mnNativeBackground = ControlPart::BackgroundDialog;
525  }
526  // fallback to settings color
527  else
528  SetBackground(GetSettings().GetStyleSettings().GetDialogColor());
529 }
530 
532 {
533  if (comphelper::LibreOfficeKit::isActive() && pParent)
534  {
535  if (VclPtr<vcl::Window> pWin = pParent->GetParentWithLOKNotifier())
536  {
537  SetLOKNotifier(pWin->GetLOKNotifier());
538  }
539  }
540 }
541 
543  : SystemWindow( nType )
544  , mnInitFlag(InitFlag::Default)
545 {
547 }
548 
550 {
551  if (m_pUIBuilder)
552  m_pUIBuilder->disposeBuilder();
553 }
554 
556 {
557  OUString sShareLayer("$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/config/soffice.cfg/");
558  rtl::Bootstrap::expandMacros(sShareLayer);
559  return sShareLayer;
560 }
561 
562 //we can't change sizeable after the fact, so need to defer until we know and then
563 //do the init. Find the real parent stashed in mpDialogParent.
565 {
567  mpDialogParent = nullptr;
568  ImplInitDialog(pParent, nBits | WB_BORDER, mnInitFlag);
569  mbIsDeferredInit = false;
570 }
571 
572 Dialog::Dialog(vcl::Window* pParent, std::u16string_view rID, const OUString& rUIXMLDescription)
574  , mnInitFlag(InitFlag::Default)
575 {
576  ImplLOKNotifier(pParent);
578  loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription);
579 }
580 
581 Dialog::Dialog(vcl::Window* pParent, WinBits nStyle, InitFlag eFlag)
583  , mnInitFlag(eFlag)
584 {
585  ImplLOKNotifier(pParent);
587  ImplInitDialog( pParent, nStyle, eFlag );
588 }
589 
591 {
592  mpActionArea.set(pBox);
593  if (pBox)
594  {
595  const DialogStyle& rDialogStyle =
597  pBox->set_border_width(rDialogStyle.action_area_border);
598  }
599 }
600 
602 {
603  mpContentArea.set(pBox);
604 }
605 
607 {
608  const DialogStyle& rDialogStyle =
610  VclBox * pBox2 = static_cast<VclBox*>(pBox);
611  pBox2->set_border_width(rDialogStyle.content_area_border);
612 }
613 
615 {
616  disposeOnce();
617 }
618 
620 {
621  bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling;
622 
623  mpDialogImpl.reset();
627 
628  css::uno::Reference< css::uno::XComponentContext > xContext(
630  css::uno::Reference<css::frame::XGlobalEventBroadcaster> xEventBroadcaster(css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_SET_THROW);
631  css::document::DocumentEvent aObject;
632  aObject.EventName = "DialogClosed";
633  xEventBroadcaster->documentEventOccured(aObject);
634  UITestLogger::getInstance().log(u"Close Dialog");
635 
637  {
638  if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
639  {
640  if (bTunnelingEnabled)
641  pNotifier->notifyWindow(GetLOKWindowId(), "close");
643  }
644  }
645 
647 }
648 
649 IMPL_LINK_NOARG(Dialog, ImplAsyncCloseHdl, void*, void)
650 {
651  Close();
652 }
653 
655 {
656  // first call the base class due to Tab control
657  bool bRet = SystemWindow::EventNotify( rNEvt );
658  if ( !bRet )
659  {
660  if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
661  {
662  const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
663  vcl::KeyCode aKeyCode = pKEvt->GetKeyCode();
664  sal_uInt16 nKeyCode = aKeyCode.GetCode();
665 
666  if ( (nKeyCode == KEY_ESCAPE) &&
667  ((GetStyle() & WB_CLOSEABLE) || ImplGetCancelButton( this ) || ImplGetOKButton( this )) )
668  {
669  // #i89505# for the benefit of slightly mentally challenged implementations
670  // like e.g. SfxModelessDialog which destroy themselves inside Close()
671  // post this Close asynchronous so we can leave our key handler before
672  // we get destroyed
673  PostUserEvent( LINK( this, Dialog, ImplAsyncCloseHdl ), nullptr, true);
674  return true;
675  }
676  }
677  else if ( rNEvt.GetType() == MouseNotifyEvent::GETFOCUS )
678  {
679  // make sure the dialog is still modal
680  // changing focus between application frames may
681  // have re-enabled input for our parent
682  if( mbInExecute && mbModalMode )
683  {
684  ImplSetModalInputMode( false );
685  ImplSetModalInputMode( true );
686 
687  // #93022# def-button might have changed after show
688  if( !mnMousePositioned )
689  {
690  mnMousePositioned = 1;
691  ImplMouseAutoPos( this );
692  }
693 
694  }
695  }
696  }
697 
698  return bRet;
699 }
700 
701 //What we really want here is something that gives the available width and
702 //height of a users screen, taking away the space taken up the OS
703 //taskbar, menus, etc.
705 {
706 #ifndef IOS
707  tools::Long w = rScreenSize.Width();
708  if (w <= 800)
709  w -= 15;
710  else if (w <= 1024)
711  w -= 65;
712  else
713  w -= 115;
714 
715  tools::Long h = rScreenSize.Height();
716  if (h <= 768)
717  h -= 50;
718  else
719  h -= 100;
720 
721  return Size(std::max<tools::Long>(w, 640 - 15),
722  std::max<tools::Long>(h, 480 - 50));
723 #else
724  // Don't bother with ancient magic numbers of unclear relevance on non-desktop apps anyway. It
725  // seems that at least currently in the iOS app, this function is called just once per dialog,
726  // with a rScreenSize parameter of 1x1 (!). This would lead to always returning 625x430 which is
727  // a bit random and needlessly small on an iPad at least. We want something that closely will
728  // just fit on the display in either orientation.
729 
730  // We ignore the rScreenSize as it will be the dummy 1x1 from iosinst.cxx (see "Totally wrong of course").
731  (void) rScreenSize;
732 
733  const int n = std::min<CGFloat>([[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height);
734  return Size(n-10, n-10);
735 #endif
736 }
737 
739 {
740  mpDialogImpl->m_aPopupMenuHdl = rLink;
741 }
742 
744 {
745  mpDialogImpl->m_aInstallLOKNotifierHdl = rLink;
746 }
747 
748 void Dialog::SetLOKTunnelingState(bool bEnabled)
749 {
750  mpDialogImpl->m_bLOKTunneling = bEnabled;
751 }
752 
754 {
755  bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling;
756 
757  if (nType == StateChangedType::InitShow)
758  {
759  DoInitialLayout();
760 
761  const bool bKitActive = comphelper::LibreOfficeKit::isActive();
762  if (bKitActive && bTunnelingEnabled)
763  {
764  std::vector<vcl::LOKPayloadItem> aItems;
765  aItems.emplace_back("type", "dialog");
766  aItems.emplace_back("size", GetSizePixel().toString());
767  if (!GetText().isEmpty())
768  aItems.emplace_back("title", GetText().toUtf8());
769 
770  if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
771  {
772  pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems);
773  pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems);
774  }
775  else
776  {
777  vcl::ILibreOfficeKitNotifier* pViewShell = mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr);
778  if (pViewShell)
779  {
780  SetLOKNotifier(pViewShell);
781  pViewShell->notifyWindow(GetLOKWindowId(), "created", aItems);
782  }
783  }
784  }
785 
786  if ( !HasChildPathFocus() || HasFocus() )
788  if ( !(GetStyle() & WB_CLOSEABLE) )
789  {
790  if ( ImplGetCancelButton( this ) || ImplGetOKButton( this ) )
791  {
792  if ( ImplGetBorderWindow() )
793  static_cast<ImplBorderWindow*>(ImplGetBorderWindow())->SetCloseButton();
794  }
795  }
796 
797  ImplMouseAutoPos( this );
798  }
799  else if (nType == StateChangedType::Text)
800  {
801  const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier();
802  if (pNotifier && bTunnelingEnabled)
803  {
804  std::vector<vcl::LOKPayloadItem> aPayload;
805  aPayload.emplace_back("title", GetText().toUtf8());
806  pNotifier->notifyWindow(GetLOKWindowId(), "title_changed", aPayload);
807  }
808  }
809 
811 
813  {
815  Invalidate();
816  }
817 
818  if (!mbModalMode && nType == StateChangedType::Visible)
819  {
820  const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier();
821  if (pNotifier && bTunnelingEnabled)
822  {
823  std::vector<vcl::LOKPayloadItem> aPayload;
824  aPayload.emplace_back("title", GetText().toUtf8());
825  pNotifier->notifyWindow(GetLOKWindowId(), IsVisible()? OUString("show"): OUString("hide"), aPayload);
826  }
827  }
828 }
829 
831 {
832  SystemWindow::DataChanged( rDCEvt );
833 
834  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
835  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
836  {
838  Invalidate();
839  }
840 }
841 
843 {
844  VclPtr<vcl::Window> xWindow = this;
846  if ( xWindow->IsDisposed() )
847  return false;
848 
849  if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() && !IsInExecute() )
850  return false;
851 
852  // If there's a cancel button with a custom handler, then always give it a chance to
853  // handle Dialog::Close
854  PushButton* pCustomCancelButton;
855  PushButton* pCancelButton = dynamic_cast<PushButton*>(get_widget_for_response(RET_CANCEL));
856  if (!mbInClose && pCancelButton && pCancelButton->GetClickHdl().IsSet())
857  pCustomCancelButton = pCancelButton;
858  else
859  pCustomCancelButton = nullptr;
860 
861  mbInClose = true;
862 
863  if (pCustomCancelButton)
864  {
865  pCustomCancelButton->Click();
866  if (xWindow->IsDisposed())
867  return true;
868  mbInClose = false;
869  return false;
870  }
871 
872  if ( !(GetStyle() & WB_CLOSEABLE) )
873  {
874  bool bRet = true;
875  PushButton* pButton = ImplGetCancelButton( this );
876  if ( pButton )
877  pButton->Click();
878  else
879  {
880  pButton = ImplGetOKButton( this );
881  if ( pButton )
882  pButton->Click();
883  else
884  bRet = false;
885  }
886  if ( xWindow->IsDisposed() )
887  return true;
888  return bRet;
889  }
890 
891  if (IsInExecute() || mpDialogImpl->maEndCtx.isSet())
892  {
893  EndDialog();
894  mbInClose = false;
895  return true;
896  }
897  else
898  {
899  mbInClose = false;
900  return SystemWindow::Close();
901  }
902 }
903 
905 {
907 
908  if (IsInExecute() || mpDialogImpl->maEndCtx.isSet())
909  {
910 #ifdef DBG_UTIL
911  SAL_WARN( "vcl", "Dialog::StartExecuteModal() is called in Dialog::StartExecuteModal(): "
912  << ImplGetDialogText(this) );
913 #endif
914  return false;
915  }
916 
917  ImplSVData* pSVData = ImplGetSVData();
918 
919  const bool bKitActive = comphelper::LibreOfficeKit::isActive();
920 
921  const bool bModal = GetType() != WindowType::MODELESSDIALOG;
922 
923  if (bModal)
924  {
925  if (bKitActive && !GetLOKNotifier())
926  SetLOKNotifier(mpDialogImpl->m_aInstallLOKNotifierHdl.Call(nullptr));
927 
929  {
931  break;
933  if (bModal && GetLOKNotifier())
934  {
935  // check if there's already some dialog being ::Execute()d
936  const bool bDialogExecuting = std::any_of(pSVData->mpWinData->mpExecuteDialogs.begin(),
937  pSVData->mpWinData->mpExecuteDialogs.end(),
938  [](const Dialog* pDialog) {
939  return pDialog->IsInSyncExecute();
940  });
941  if (!(bDialogExecuting && IsInSyncExecute()))
942  break;
943  else
944  SAL_WARN("lok.dialog", "Dialog \"" << ImplGetDialogText(this) << "\" is being synchronously executed over an existing synchronously executing dialog.");
945  }
946 
947  SAL_INFO(
948  "vcl",
949  "Dialog \"" << ImplGetDialogText(this)
950  << "\"cancelled in silent mode");
951  return false;
952 
954  return false;
955 
956  default: // default cannot happen
958  std::abort();
959  }
960 
961 #ifdef DBG_UTIL
962  vcl::Window* pParent = GetParent();
963  if ( pParent )
964  {
965  pParent = pParent->ImplGetFirstOverlapWindow();
966  SAL_WARN_IF( !pParent->IsReallyVisible(), "vcl",
967  "Dialog::StartExecuteModal() - Parent not visible" );
968  SAL_WARN_IF( !pParent->IsInputEnabled(), "vcl",
969  "Dialog::StartExecuteModal() - Parent input disabled, use another parent to ensure modality!" );
970  SAL_WARN_IF( pParent->IsInModalMode(), "vcl",
971  "Dialog::StartExecuteModal() - Parent already modally disabled, use another parent to ensure modality!" );
972  }
973 #endif
974 
975  // link all dialogs which are being executed
976  pSVData->mpWinData->mpExecuteDialogs.push_back(this);
977 
978  // stop capturing, in order to have control over the dialog
979  if (pSVData->mpWinData->mpTrackWin)
981  if (pSVData->mpWinData->mpCaptureWin)
982  pSVData->mpWinData->mpCaptureWin->ReleaseMouse();
983  EnableInput();
984  }
985 
986  mbInExecute = true;
987  // no real modality in LibreOfficeKit
988  if (!bKitActive && bModal)
989  SetModalInputMode(true);
990 
991  // FIXME: no layouting, workaround some clipping issues
993 
994  css::uno::Reference< css::uno::XComponentContext > xContext(
996  bool bForceFocusAndToFront(officecfg::Office::Common::View::NewDocumentHandling::ForceFocusAndToFront::get(xContext));
997  ShowFlags showFlags = bForceFocusAndToFront ? ShowFlags::ForegroundTask : ShowFlags::NONE;
998  Show(true, showFlags);
999 
1000  if (bModal)
1001  pSVData->maAppData.mnModalMode++;
1002 
1003  css::uno::Reference<css::frame::XGlobalEventBroadcaster> xEventBroadcaster(
1004  css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_SET_THROW);
1005  css::document::DocumentEvent aObject;
1006  aObject.EventName = "DialogExecute";
1007  xEventBroadcaster->documentEventOccured(aObject);
1008  if (bModal)
1009  UITestLogger::getInstance().log(OUString("Open Modal " + get_id()));
1010  else
1011  UITestLogger::getInstance().log(OUString("Open Modeless " + get_id()));
1012 
1013  bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling;
1014  if (comphelper::LibreOfficeKit::isActive() && bTunnelingEnabled)
1015  {
1016  if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
1017  {
1018  // Dialog boxes don't get the Resize call and they
1019  // can have invalid size at 'created' message above.
1020  // If there is no difference, the client should detect it and ignore us,
1021  // otherwise, this should make sure that the window has the correct size.
1022  std::vector<vcl::LOKPayloadItem> aItems;
1023  aItems.emplace_back("size", GetSizePixel().toString());
1024  pNotifier->notifyWindow(GetLOKWindowId(), "size_changed", aItems);
1025  }
1026  }
1027 
1028  return true;
1029 }
1030 
1032 {
1033  ImplSVData* pSVData = ImplGetSVData();
1034  pSVData->maAppData.mnModalMode--;
1035 }
1036 
1038 {
1039 // Once the Android app is based on same idea as the iOS one currently
1040 // being developed, no conditional should be needed here. Until then,
1041 // play it safe.
1042 #if HAVE_FEATURE_DESKTOP || defined IOS
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
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 #else
1075  return RET_OK;
1076 #endif
1077 }
1078 
1079 // virtual
1081 {
1082  const bool bModal = GetType() != WindowType::MODELESSDIALOG;
1083  if (!ImplStartExecute())
1084  {
1085  rCtx.mxOwner.disposeAndClear();
1086  rCtx.mxOwnerDialogController.reset();
1087  rCtx.mxOwnerSelf.reset();
1088  return false;
1089  }
1090 
1091  mpDialogImpl->maEndCtx = rCtx;
1092  mpDialogImpl->mbStartedModal = bModal;
1093 
1094  return true;
1095 }
1096 
1098 {
1099  ImplSVData* pSVData = ImplGetSVData();
1100  auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
1101 
1102  // remove dialog from the list of dialogs which are being executed
1103  rExecuteDialogs.erase(std::remove_if(rExecuteDialogs.begin(), rExecuteDialogs.end(), [this](VclPtr<Dialog>& dialog){ return dialog.get() == this; }), rExecuteDialogs.end());
1104 }
1105 
1107 {
1108  if (!mbInExecute || IsDisposed())
1109  return;
1110 
1111  const bool bModal = GetType() != WindowType::MODELESSDIALOG;
1112 
1113  Hide();
1114 
1116  {
1117  if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
1118  {
1119  pNotifier->notifyWindow(GetLOKWindowId(), "close");
1121  }
1122  }
1123 
1124  if (bModal)
1125  {
1126  SetModalInputMode(false);
1127 
1129 
1130  // set focus to previous modal dialog if it is modal for
1131  // the same frame parent (or NULL)
1132  ImplSVData* pSVData = ImplGetSVData();
1133  if (!pSVData->mpWinData->mpExecuteDialogs.empty())
1134  {
1135  VclPtr<Dialog> pPrevious = pSVData->mpWinData->mpExecuteDialogs.back();
1136 
1137  vcl::Window* pFrameParent = ImplGetFrameWindow()->ImplGetParent();
1138  vcl::Window* pPrevFrameParent = pPrevious->ImplGetFrameWindow()? pPrevious->ImplGetFrameWindow()->ImplGetParent(): nullptr;
1139  if( ( !pFrameParent && !pPrevFrameParent ) ||
1140  ( pFrameParent && pPrevFrameParent && pFrameParent->ImplGetFrame() == pPrevFrameParent->ImplGetFrame() )
1141  )
1142  {
1143  pPrevious->GrabFocus();
1144  }
1145  }
1146  }
1147 
1148  mpDialogImpl->mnResult = nResult;
1149 
1150  if ( mpDialogImpl->mbStartedModal )
1152 
1153  if ( mpDialogImpl && mpDialogImpl->maEndCtx.isSet() )
1154  {
1155  auto fn = std::move(mpDialogImpl->maEndCtx.maEndDialogFn);
1156  // std::move leaves maEndDialogFn in a valid state with unspecified
1157  // value. For the SwSyncBtnDlg case gcc and msvc left maEndDialogFn
1158  // unset, but clang left maEndDialogFn at its original value, keeping
1159  // an extra reference to the DialogController in its lambda giving
1160  // an inconsistent lifecycle for the dialog. Force it to be unset.
1161  mpDialogImpl->maEndCtx.maEndDialogFn = nullptr;
1162  fn(nResult);
1163  }
1164 
1165  if ( mpDialogImpl && mpDialogImpl->mbStartedModal )
1166  {
1167  mpDialogImpl->mbStartedModal = false;
1168  mpDialogImpl->mnResult = -1;
1169  }
1170  mbInExecute = false;
1171 
1172  if ( mpDialogImpl )
1173  {
1174  // Destroy ourselves (if we have a context with VclPtr owner)
1175  std::shared_ptr<weld::DialogController> xOwnerDialogController = std::move(mpDialogImpl->maEndCtx.mxOwnerDialogController);
1176  std::shared_ptr<weld::Dialog> xOwnerSelf = std::move(mpDialogImpl->maEndCtx.mxOwnerSelf);
1177  mpDialogImpl->maEndCtx.mxOwner.disposeAndClear();
1178  xOwnerDialogController.reset();
1179  xOwnerSelf.reset();
1180  }
1181 }
1182 
1183 namespace vcl
1184 {
1185  void EndAllDialogs( vcl::Window const * pParent )
1186  {
1187  ImplSVData* pSVData = ImplGetSVData();
1188  auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
1189 
1190  for (auto it = rExecuteDialogs.rbegin(); it != rExecuteDialogs.rend(); ++it)
1191  {
1192  if (!pParent || pParent->IsWindowOrChild(*it, true))
1193  {
1194  (*it)->EndDialog();
1195  (*it)->PostUserEvent(Link<void*, void>());
1196  }
1197  }
1198  }
1199 
1201  {
1202  if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow))
1203  {
1204  pDialog->EnableInput();
1205  }
1206  }
1207 
1209  {
1210  if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow))
1211  pDialog->Close();
1212  else if (FloatingWindow* pFloatWin = dynamic_cast<FloatingWindow*>(pWindow))
1214  }
1215 }
1216 
1217 void Dialog::SetModalInputMode( bool bModal )
1218 {
1219  if ( bModal == mbModalMode )
1220  return;
1221 
1222  ImplGetFrame()->SetModal(bModal);
1223 
1224  if (GetParent())
1225  {
1226  SalFrame* pFrame = GetParent()->ImplGetFrame();
1227  pFrame->NotifyModalHierarchy(bModal);
1228  }
1229 
1230  ImplSetModalInputMode(bModal);
1231 }
1232 
1234 {
1235  if ( bModal == mbModalMode )
1236  return;
1237 
1238  // previously Execute()'d dialog - the one below the top-most one
1239  VclPtr<Dialog> pPrevious;
1240  ImplSVData* pSVData = ImplGetSVData();
1241  auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
1242  if (rExecuteDialogs.size() > 1)
1243  pPrevious = rExecuteDialogs[rExecuteDialogs.size() - 2];
1244 
1245  mbModalMode = bModal;
1246  if ( bModal )
1247  {
1248  // Disable the prev Modal Dialog, because our dialog must close at first,
1249  // before the other dialog can be closed (because the other dialog
1250  // is on stack since our dialog returns)
1251  if (pPrevious && !pPrevious->IsWindowOrChild(this, true))
1252  pPrevious->EnableInput(false, this);
1253 
1254  // determine next overlap dialog parent
1255  vcl::Window* pParent = GetParent();
1256  if ( pParent )
1257  {
1258  // #103716# dialogs should always be modal to the whole frame window
1259  // #115933# disable the whole frame hierarchy, useful if our parent
1260  // is a modeless dialog
1261  mpDialogParent = pParent->mpWindowImpl->mpFrameWindow;
1263  }
1264  }
1265  else
1266  {
1267  if ( mpDialogParent )
1268  {
1269  // #115933# re-enable the whole frame hierarchy again (see above)
1270  // note that code in getfocus assures that we do not accidentally enable
1271  // windows that were disabled before
1273  }
1274 
1275  // Enable the prev Modal Dialog
1276  if (pPrevious && !pPrevious->IsWindowOrChild(this, true))
1277  {
1278  pPrevious->EnableInput(true, this);
1279 
1280  // ensure continued modality of prev dialog
1281  // do not change modality counter
1282 
1283  // #i119994# need find the last modal dialog before reactive it
1284  if (pPrevious->IsModalInputMode() || !pPrevious->IsWindowOrChild(this, true))
1285  {
1286  pPrevious->ImplSetModalInputMode(false);
1287  pPrevious->ImplSetModalInputMode(true);
1288  }
1289  }
1290  }
1291 }
1292 
1294 {
1295  vcl::Window* pFocusControl;
1296 
1297  // find focus control, even if the dialog has focus
1298  if ( HasFocus() )
1299  pFocusControl = nullptr;
1300  else
1301  {
1302  // prefer a child window which had focus before
1303  pFocusControl = ImplGetFirstOverlapWindow()->mpWindowImpl->mpLastFocusWindow;
1304  // find the control out of the dialog control
1305  if ( pFocusControl )
1306  pFocusControl = ImplFindDlgCtrlWindow( pFocusControl );
1307  }
1308  // no control had the focus before or the control is not
1309  // part of the tab-control, now give focus to the
1310  // first control in the tab-control
1311  if ( !pFocusControl ||
1312  !(pFocusControl->GetStyle() & WB_TABSTOP) ||
1313  !isVisibleInLayout(pFocusControl) ||
1314  !isEnabledInLayout(pFocusControl) || !pFocusControl->IsInputEnabled() )
1315  {
1316  pFocusControl = ImplGetDlgWindow( 0, GetDlgWindowType::First );
1317  }
1318  if ( pFocusControl )
1319  pFocusControl->ImplControlFocus( GetFocusFlags::Init );
1320 }
1321 
1322 void Dialog::GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
1323 {
1324  ScopedVclPtrInstance<ImplBorderWindow> aImplWin( static_cast<vcl::Window*>(const_cast<Dialog *>(this)), WB_BORDER|WB_STDWORK, BorderWindowStyle::Overlap );
1325  aImplWin->GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder );
1326 }
1327 
1328 void Dialog::Draw( OutputDevice* pDev, const Point& rPos, DrawFlags )
1329 {
1330  Point aPos = pDev->LogicToPixel( rPos );
1331  Size aSize = GetSizePixel();
1332 
1333  Wallpaper aWallpaper = GetBackground();
1334  if ( !aWallpaper.IsBitmap() )
1335  ImplInitSettings();
1336 
1337  pDev->Push();
1338  pDev->SetMapMode();
1339  pDev->SetLineColor();
1340 
1341  if ( aWallpaper.IsBitmap() )
1342  pDev->DrawBitmapEx( aPos, aSize, aWallpaper.GetBitmap() );
1343  else
1344  {
1345  pDev->SetFillColor( aWallpaper.GetColor() );
1346  pDev->DrawRect( tools::Rectangle( aPos, aSize ) );
1347  }
1348 
1349  if (!( GetStyle() & WB_NOBORDER ))
1350  {
1352  aImplWin->SetText( GetText() );
1353  aImplWin->setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
1354  aImplWin->SetDisplayActive( true );
1355  aImplWin->InitView();
1356 
1357  aImplWin->Draw( pDev, aPos );
1358  }
1359 
1360  pDev->Pop();
1361 }
1362 
1364 {
1365  if (IsInClose())
1366  return;
1367  SystemWindow::queue_resize(eReason);
1368 }
1369 
1371 {
1373 
1375  return;
1376 
1377  bool bTunnelingEnabled = mpDialogImpl->m_bLOKTunneling;
1378  const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier();
1379  if (pNotifier && bTunnelingEnabled)
1380  {
1381  std::vector<vcl::LOKPayloadItem> aItems;
1382  aItems.emplace_back("size", GetSizePixel().toString());
1383  pNotifier->notifyWindow(GetLOKWindowId(), "size_changed", aItems);
1384  }
1385 }
1386 
1387 bool Dialog::set_property(const OString &rKey, const OUString &rValue)
1388 {
1389  if (rKey == "border-width")
1390  set_border_width(rValue.toInt32());
1391  else
1392  return SystemWindow::set_property(rKey, rValue);
1393  return true;
1394 }
1395 
1397 {
1398  return DialogUIObject::create;
1399 }
1400 
1401 IMPL_LINK(Dialog, ResponseHdl, Button*, pButton, void)
1402 {
1403  auto aFind = mpDialogImpl->maResponses.find(pButton);
1404  if (aFind == mpDialogImpl->maResponses.end())
1405  return;
1406  short nResponse = aFind->second;
1407  if (nResponse == RET_HELP)
1408  {
1410  if (!pFocusWin || comphelper::LibreOfficeKit::isActive())
1411  pFocusWin = pButton;
1413  pFocusWin->RequestHelp(aEvt);
1414  return;
1415  }
1416  EndDialog(nResponse);
1417 }
1418 
1419 void Dialog::add_button(PushButton* pButton, int response, bool bTransferOwnership)
1420 {
1421  if (bTransferOwnership)
1422  mpDialogImpl->maOwnedButtons.push_back(pButton);
1423  mpDialogImpl->maResponses[pButton] = response;
1424  switch (pButton->GetType())
1425  {
1426  case WindowType::PUSHBUTTON:
1427  {
1428  if (!pButton->GetClickHdl().IsSet())
1429  pButton->SetClickHdl(LINK(this, Dialog, ResponseHdl));
1430  break;
1431  }
1432  //insist that the response ids match the default actions for those
1433  //widgets, and leave their default handlers in place
1434  case WindowType::OKBUTTON:
1435  assert(mpDialogImpl->get_response(pButton) == RET_OK);
1436  break;
1437  case WindowType::CANCELBUTTON:
1438  assert(mpDialogImpl->get_response(pButton) == RET_CANCEL || mpDialogImpl->get_response(pButton) == RET_CLOSE);
1439  break;
1440  case WindowType::HELPBUTTON:
1441  assert(mpDialogImpl->get_response(pButton) == RET_HELP);
1442  break;
1443  default:
1444  SAL_WARN("vcl.layout", "The type of widget " <<
1445  pButton->GetHelpId() << " is currently not handled");
1446  break;
1447  }
1448 }
1449 
1451 {
1452  //copy explicit responses
1453  std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses);
1454 
1455  if (mpActionArea)
1456  {
1457  //add implicit responses
1459  pChild = pChild->GetWindow(GetWindowType::Next))
1460  {
1461  if (aResponses.find(pChild) != aResponses.end())
1462  continue;
1463  switch (pChild->GetType())
1464  {
1465  case WindowType::OKBUTTON:
1466  aResponses[pChild] = RET_OK;
1467  break;
1468  case WindowType::CANCELBUTTON:
1469  aResponses[pChild] = RET_CANCEL;
1470  break;
1471  case WindowType::HELPBUTTON:
1472  aResponses[pChild] = RET_HELP;
1473  break;
1474  default:
1475  break;
1476  }
1477  }
1478  }
1479 
1480  for (const auto& a : aResponses)
1481  {
1482  if (a.second == response)
1483  return a.first;
1484  }
1485 
1486  return nullptr;
1487 }
1488 
1490 {
1491  //copy explicit responses
1492  std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses);
1493 
1494  if (mpActionArea)
1495  {
1496  //add implicit responses
1498  pChild = pChild->GetWindow(GetWindowType::Next))
1499  {
1500  if (aResponses.find(pChild) != aResponses.end())
1501  continue;
1502  switch (pChild->GetType())
1503  {
1504  case WindowType::OKBUTTON:
1505  aResponses[pChild] = RET_OK;
1506  break;
1507  case WindowType::CANCELBUTTON:
1508  aResponses[pChild] = RET_CANCEL;
1509  break;
1510  case WindowType::HELPBUTTON:
1511  aResponses[pChild] = RET_HELP;
1512  break;
1513  default:
1514  break;
1515  }
1516  }
1517  }
1518 
1519  for (const auto& a : aResponses)
1520  {
1521  if (a.first->GetStyle() & WB_DEFBUTTON)
1522  {
1523  return a.second;
1524  }
1525  }
1526  return RET_CANCEL;
1527 }
1528 
1530 {
1531  //copy explicit responses
1532  std::map<VclPtr<vcl::Window>, short> aResponses(mpDialogImpl->maResponses);
1533 
1534  if (mpActionArea)
1535  {
1536  //add implicit responses
1538  pChild = pChild->GetWindow(GetWindowType::Next))
1539  {
1540  if (aResponses.find(pChild) != aResponses.end())
1541  continue;
1542  switch (pChild->GetType())
1543  {
1544  case WindowType::OKBUTTON:
1545  aResponses[pChild] = RET_OK;
1546  break;
1547  case WindowType::CANCELBUTTON:
1548  aResponses[pChild] = RET_CANCEL;
1549  break;
1550  case WindowType::HELPBUTTON:
1551  aResponses[pChild] = RET_HELP;
1552  break;
1553  default:
1554  break;
1555  }
1556  }
1557  }
1558 
1559  for (auto& a : aResponses)
1560  {
1561  if (a.second == response)
1562  {
1563  a.first->SetStyle(a.first->GetStyle() | WB_DEFBUTTON);
1564  a.first->GrabFocus();
1565  }
1566  else
1567  {
1568  a.first->SetStyle(a.first->GetStyle() & ~WB_DEFBUTTON);
1569  }
1570  }
1571 }
1572 
1574 {
1575 }
1576 
1578 {
1579  if (!m_pUIBuilder)
1580  return;
1581  m_pUIBuilder->setDeferredProperties();
1582 }
1583 
1585 {
1586 }
1587 
1589 {
1590  if (GetType() == WindowType::MODELESSDIALOG)
1591  {
1592  css::uno::Reference< css::uno::XComponentContext > xContext(
1594  css::uno::Reference<css::frame::XGlobalEventBroadcaster> xEventBroadcaster(css::frame::theGlobalEventBroadcaster::get(xContext), css::uno::UNO_SET_THROW);
1595  css::document::DocumentEvent aObject;
1596  aObject.EventName = "ModelessDialogVisible";
1597  xEventBroadcaster->documentEventOccured(aObject);
1598  }
1600 }
1601 
1602 void Dialog::Command(const CommandEvent& rCEvt)
1603 {
1604  if (mpDialogImpl && mpDialogImpl->m_aPopupMenuHdl.Call(rCEvt))
1605  return;
1606  SystemWindow::Command(rCEvt);
1607 }
1608 
1610 {
1611  std::stack<std::vector<VclPtr<vcl::Window>>> m_aBusyStack;
1612 };
1613 
1615  : m_xImpl(std::make_unique<TopLevelWindowLockerImpl>())
1616 {
1617 }
1618 
1620 {
1621  // lock any toplevel windows from being closed until busy is over
1622  std::vector<VclPtr<vcl::Window>> aTopLevels;
1624  while (pTopWin)
1625  {
1626  vcl::Window* pCandidate = pTopWin;
1627  if (pCandidate->GetType() == WindowType::BORDERWINDOW)
1628  pCandidate = pCandidate->GetWindow(GetWindowType::FirstChild);
1629  // tdf#125266 ignore HelpTextWindows
1630  if (pCandidate &&
1631  pCandidate->GetType() != WindowType::HELPTEXTWINDOW &&
1632  pCandidate->GetType() != WindowType::FLOATINGWINDOW &&
1633  pCandidate->GetFrameWeld() != pIgnore)
1634  {
1635  aTopLevels.push_back(pCandidate);
1636  }
1637  pTopWin = Application::GetNextTopLevelWindow(pTopWin);
1638  }
1639  for (auto& a : aTopLevels)
1640  {
1641  a->IncModalCount();
1642  a->ImplGetFrame()->NotifyModalHierarchy(true);
1643  }
1644  m_xImpl->m_aBusyStack.push(aTopLevels);
1645 }
1646 
1648 {
1649  // unlock locked toplevel windows from being closed now busy is over
1650  for (auto& a : m_xImpl->m_aBusyStack.top())
1651  {
1652  if (a->IsDisposed())
1653  continue;
1654  a->DecModalCount();
1655  a->ImplGetFrame()->NotifyModalHierarchy(false);
1656  }
1657  m_xImpl->m_aBusyStack.pop();
1658 }
1659 
1661 {
1662  return !m_xImpl->m_aBusyStack.empty();
1663 }
1664 
1666 {
1667 }
1668 
1670 {
1671  SystemWindow::DumpAsPropertyTree(rJsonWriter);
1672  rJsonWriter.put("title", GetText());
1673  if (vcl::Window* pActionArea = get_action_area())
1674  {
1675  if (!pActionArea->IsVisible())
1676  rJsonWriter.put("collapsed", "true");
1677  }
1678 
1679  OUString sDialogId = OStringToOUString(GetHelpId(), RTL_TEXTENCODING_ASCII_US);
1680  sal_Int32 nStartPos = sDialogId.lastIndexOf('/');
1681  nStartPos = nStartPos >= 0 ? nStartPos + 1 : 0;
1682  rJsonWriter.put("dialogid", sDialogId.copy(nStartPos));
1683 
1684  {
1685  auto aResponses = rJsonWriter.startArray("responses");
1686  for (auto& rResponse : mpDialogImpl->maResponses)
1687  {
1688  auto aResponse = rJsonWriter.startStruct();
1689  rJsonWriter.put("id", rResponse.first->get_id());
1690  rJsonWriter.put("response", rResponse.second);
1691  }
1692  }
1693 }
1694 
1695 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE void ImplInitDialogData()
Definition: dialog.cxx:386
virtual void SetText(const OUString &rStr)
Definition: window.cxx:3007
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:1086
bool IsInputEnabled() const
Definition: window2.cxx:1126
vcl::Window * ImplGetWindow() const
if this is a proxy return the client, otherwise itself
Definition: window2.cxx:834
Point GetPointerPosPixel()
Definition: mouse.cxx:549
const Wallpaper & GetBackground() const
Definition: outdev.hxx:642
void setDeferredProperties()
Definition: dialog.cxx:1577
vcl::LOKWindowId GetLOKWindowId() const
Definition: window.cxx:3225
OUString sMessage
std::stack< std::vector< VclPtr< vcl::Window > > > m_aBusyStack
Definition: dialog.cxx:1611
bool GetAutoMnemonic() const
WinBits const WB_SYSTEMWINDOW
bool isVisibleInLayout(const vcl::Window *pWindow)
Definition: layout.cxx:2849
vcl::Window * lastLogicalChildOfParent(const vcl::Window *pTopLevel)
Definition: dialog.cxx:196
WinBits const WB_NOLABEL
void log(std::u16string_view rString)
Definition: logger.cxx:182
void set_border_width(sal_Int32 nBorderWidth)
Definition: window2.cxx:1835
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: dialog.cxx:654
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: dialog.cxx:1363
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:842
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: syswin.cxx:171
virtual ~Dialog() override
Definition: dialog.cxx:614
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:1106
void DecModalCount()
Definition: window.cxx:3576
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...
static vcl::Window * GetDefDialogParent()
Get the default parent window for dialog boxes.
Definition: svapp.cxx:1383
silently cancel any dialogs (LOK case)
std::vector< VclPtr< PushButton > > maOwnedButtons
Definition: dialog.cxx:352
ImplSVAppData maAppData
Definition: svdata.hxx:391
long Long
void disposeAndClear()
Definition: vclptr.hxx:200
void SetDisplayActive(bool bActive)
Definition: brdwin.cxx:1861
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:124
sal_Int64 n
SAL_DLLPRIVATE vcl::Window * ImplGetBorderWindow() const
Definition: window2.cxx:874
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual Size GetSizePixel() const
Definition: window.cxx:2383
SAL_DLLPRIVATE vcl::Window * ImplGetFrameWindow() const
Definition: window2.cxx:900
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
Definition: dialog.cxx:1328
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:3150
sal_uInt16 GetCode() const
Definition: keycod.hxx:51
Link< void *, vcl::ILibreOfficeKitNotifier * > m_aInstallLOKNotifierHdl
Definition: dialog.cxx:358
DataChangedEventType GetType() const
Definition: event.hxx:354
const KeyEvent * GetKeyEvent() const
Definition: event.hxx:308
OUString CreateMnemonic(const OUString &rKey)
Definition: mnemonic.cxx:121
const Color & GetControlBackground() const
Definition: window2.cxx:1081
bool IsCreatedWithToolkit() const
Definition: window2.cxx:1236
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:2985
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:551
std::shared_ptr< weld::DialogController > mxOwnerDialogController
Definition: abstdlg.hxx:61
virtual FactoryFunction GetUITestFactory() const override
Definition: dialog.cxx:1396
IMPL_LINK(Dialog, ResponseHdl, Button *, pButton, void)
Definition: dialog.cxx:1401
bool isBusy() const
Definition: dialog.cxx:1660
SAL_DLLPRIVATE vcl::Window * ImplFindDlgCtrlWindow(vcl::Window *pWindow)
Definition: dlgctrl.cxx:1099
StateChangedType
Definition: window.hxx:288
constexpr tools::Long Width() const
static UITestLogger & getInstance()
Definition: logger.cxx:612
weld::Window * GetFrameWeld() const
Definition: window2.cxx:852
A construction helper for ScopedVclPtr.
Definition: vclptr.hxx:407
sal_Int64 WinBits
void SetBackground()
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: dialog.cxx:619
const OUString & get_id() const
Get the ID of the window.
Definition: window.cxx:3895
void GrabFocusToFirstControl()
Definition: dialog.cxx:1293
VclPtr< vcl::Window > GetParentWithLOKNotifier()
Find the nearest parent with LOK Notifier; can be itself if this Window has LOK notifier set...
Definition: window.cxx:3230
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3330
void EnableDialogInput(vcl::Window *pWindow)
Definition: dialog.cxx:1200
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
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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:300
void Hide()
Definition: window.hxx:918
AllSettingsFlags GetFlags() const
Definition: event.hxx:355
void set_default_response(int nResponse)
Definition: dialog.cxx:1529
bool mbInSyncExecute
Definition: dialog.hxx:56
virtual void Click()
Definition: button.cxx:126
bool IsModalInputMode() const
Definition: dialog.hxx:146
virtual OUString GetText() const
Definition: window.cxx:3036
static SystemWindowFlags GetSystemWindowMode()
Get the system window mode of dialogs.
Definition: svapp.cxx:1460
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
void CloseTopLevel(vcl::Window *pWindow)
Definition: dialog.cxx:1208
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:520
void IncModalCount()
Definition: window.cxx:3562
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:835
void ImplInitDialog(vcl::Window *pParent, WinBits nStyle, InitFlag eFlag=InitFlag::Default)
Definition: dialog.cxx:443
vcl::Window * firstLogicalChildOfParent(const vcl::Window *pTopLevel)
Definition: dialog.cxx:188
virtual bool Close()
Definition: syswin.cxx:266
void EnableInput(bool bEnable=true, bool bChild=true)
Definition: window.cxx:2474
const DialogStyle & GetDialogStyle() const
static vcl::Window * GetFirstTopLevelWindow()
Get the first top-level window of the application.
Definition: svapp.cxx:1078
static OUString GetUIRootDir()
Definition: dialog.cxx:555
WinBits const WB_DIALOGCONTROL
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:74
bool mbInClose
Definition: dialog.hxx:57
void SetLineColor()
const OString & GetHelpId() const
Definition: window2.cxx:827
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:252
void SetLOKTunnelingState(bool bEnabled)
Definition: dialog.cxx:748
VclPtr< vcl::Window > mpCaptureWin
Definition: svdata.hxx:249
bool isEnabledInLayout(const vcl::Window *pWindow)
Definition: layout.cxx:2862
void SetActivateMode(ActivateModeFlags nMode)
Definition: window.cxx:2616
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: dialog.cxx:495
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: dialog.cxx:1387
static 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:149
SAL_DLLPRIVATE VclPtr< vcl::Window > AddBorderWindow(vcl::Window *pParent, WinBits nBits)
Definition: dialog.cxx:431
bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx)
Commence execution of a modal dialog, disposes owner on failure.
Definition: dialog.cxx:1080
DrawFlags
Definition: window.hxx:331
uno_Any a
VclPtr< vcl::Window > mpIntroWindow
Definition: svdata.hxx:399
void EndAllDialogs(vcl::Window const *pParent)
Definition: dialog.cxx:1185
VclAbstractDialog::AsyncContext maEndCtx
Definition: dialog.cxx:356
int get_default_response() const
Definition: dialog.cxx:1489
SystemWindowFlags
Definition: svapp.hxx:87
void SetInstallLOKNotifierHdl(const Link< void *, vcl::ILibreOfficeKitNotifier * > &rLink)
Definition: dialog.cxx:743
VclPtr< WorkWindow > mpAppWin
Definition: svdata.hxx:240
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1140
const Color & GetColor() const
Definition: wall.hxx:71
vcl::Window * get_widget_for_response(int nResponse)
Definition: dialog.cxx:1450
bool mbInExecute
Definition: dialog.hxx:55
void SetFillColor()
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:288
float u
void add_button(PushButton *pButton, int nResponse, bool bTransferOwnership)
Definition: dialog.cxx:1419
static vcl::Window * getActionAreaButtonList(Dialog const *pDialog)
Definition: dialog.cxx:273
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:492
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:3557
int content_area_border
Definition: settings.hxx:142
sal_Int32 w
SAL_DLLPRIVATE vcl::Window * ImplGetParent() const
Definition: window2.cxx:864
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:920
MouseNotifyEvent GetType() const
Definition: event.hxx:300
void Activate() override
Definition: dialog.cxx:1588
~DialogImpl()
Definition: dialog.cxx:373
tools::Long mnResult
Definition: dialog.cxx:354
const AllSettings & GetSettings() const
Definition: outdev.hxx:405
Size GetOutputSizePixel() const
Definition: outdev.hxx:428
bool IsInExecute() const
Definition: dialog.hxx:122
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1444
void SetPopupMenuHdl(const Link< const CommandEvent &, bool > &rLink)
Definition: dialog.cxx:738
short get_response(vcl::Window *pWindow) const
Definition: dialog.cxx:364
static void ImplEndExecuteModal()
Definition: dialog.cxx:1031
static PushButton * ImplGetDefaultButton(Dialog const *pDialog)
Definition: dialog.cxx:281
void GrabFocus()
Definition: window.cxx:2957
vcl::Window * GetParent() const
Definition: window2.cxx:1096
VclPtr< vcl::Window > mpTrackWin
Definition: svdata.hxx:254
static DialogCancelMode GetDialogCancelMode()
Gets the dialog cancel mode for headless environments.
Definition: svapp.cxx:1440
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:1037
InitFlag
Definition: dialog.hxx:43
void disposeBuilder()
Definition: dialog.cxx:549
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:835
bool m_bLOKTunneling
Definition: dialog.cxx:359
void ReleaseMouse()
Definition: mouse.cxx:457
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:2647
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:926
WinBits const WB_SIZEABLE
WinBits const WB_STANDALONE
SAL_DLLPRIVATE vcl::Window * ImplGetFirstOverlapWindow()
Definition: window2.cxx:879
VclButtonBox * get_action_area()
Definition: dialog.hxx:116
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:275
SalFrame * ImplGetFrame() const
Definition: window2.cxx:847
virtual void Resize() override
Definition: dialog.cxx:1370
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:1068
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:753
WinBits const WB_STDWORK
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: syswin.cxx:993
void Draw(OutputDevice *pDev, const Point &rPos)
Definition: brdwin.cxx:1624
IMPL_LINK_NOARG(Dialog, ImplAsyncCloseHdl, void *, void)
Definition: dialog.cxx:649
vcl::Window * prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild)
Definition: dialog.cxx:160
SAL_DLLPRIVATE bool ImplIsDefButton() const
Definition: button.cxx:1169
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:1084
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:904
constexpr sal_uInt16 KEY_ESCAPE
Definition: keycodes.hxx:120
virtual void Command(const CommandEvent &rCEvt) override
Definition: dialog.cxx:1602
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: brdwin.cxx:1956
ImplSVFrameData maFrameData
Definition: svdata.hxx:393
bool IsVisible() const
Definition: window2.cxx:1101
virtual OUString GetText() const override
Definition: syswin.cxx:1063
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:1021
void set_content_area(VclBox *pBox)
Definition: dialog.cxx:601
cancel any dialogs by std::abort
SAL_DLLPRIVATE void ImplInitSettings()
Definition: dialog.cxx:515
VclPtr< VclReferenceBase > mxOwner
Definition: abstdlg.hxx:59
Reference< XComponentContext > getProcessComponentContext()
const MouseSettings & GetMouseSettings() const
void set_action_area(VclButtonBox *pBox)
Definition: dialog.cxx:590
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:1819
bool IsDisposed() const
Definition: window.cxx:139
WinBits const WB_TABSTOP
VclPtr< vcl::Window > mpDialogParent
Definition: syswin.hxx:114
bool IsBitmap() const
Definition: wall.cxx:189
WindowType GetType() const
Definition: window2.cxx:973
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1922
ShowFlags
Definition: vclenum.hxx:391
const vcl::ILibreOfficeKitNotifier * GetLOKNotifier() const
Definition: window.cxx:3220
#define SAL_WARN(area, stream)
DialogImpl()
Definition: dialog.cxx:361
WinBits GetStyle() const
Definition: window2.cxx:952
void ReleaseLOKNotifier()
Indicate that LOK is not going to use this dialog any more.
Definition: window.cxx:3188
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:1905
bool IsReallyVisible() const
Definition: window2.cxx:1106
virtual ~VclBuilderContainer()
Definition: dialog.cxx:1584
std::unique_ptr< DialogImpl > mpDialogImpl
Definition: dialog.hxx:53
SAL_DLLPRIVATE bool IsInClose() const
Definition: dialog.hxx:84
bool HasFocus() const
Definition: window.cxx:2962
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:59
void ImplLOKNotifier(vcl::Window *pParent)
Find and set the LOK notifier according to the pParent.
Definition: dialog.cxx:531
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1851
void RegisterMnemonic(const OUString &rKey)
Definition: mnemonic.cxx:81
sal_Int32 h
virtual void doDeferredInit(WinBits nBits) override
Definition: dialog.cxx:564
virtual void Resize() override
Definition: syswin.cxx:1005
bool isLayoutEnabled() const
Definition: syswin.cxx:1010
SAL_DLLPRIVATE void RemoveFromDlgList()
Definition: dialog.cxx:1097
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: dialog.cxx:830
void ImplSetModalInputMode(bool bModal)
Definition: dialog.cxx:1233
void SetModalInputMode(bool bModal)
Definition: dialog.cxx:1217
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:1669
tools::Long mnMousePositioned
Definition: dialog.hxx:54
SAL_DLLPRIVATE void DoInitialLayout()
Definition: syswin.cxx:1094
void GetDrawWindowBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: dialog.cxx:1322
virtual void settingOptimalLayoutSize(Window *pBox) override
Definition: dialog.cxx:606
WinBits const WB_ALLOWMENUBAR
void incBusy(const weld::Widget *pIgnore)
Definition: dialog.cxx:1619
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
OUString toString(OptionInfo const *info)
ImplSVWinData * mpWinData
Definition: svdata.hxx:394
Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize)
Definition: dialog.cxx:704
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:2169
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo