LibreOffice Module vcl (master)  1
svapp.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_features.h>
21 
22 #include <osl/file.hxx>
23 #include <osl/thread.hxx>
24 #include <osl/module.hxx>
25 #include <rtl/ustrbuf.hxx>
26 
27 #include <sal/log.hxx>
28 
29 #include <tools/debug.hxx>
30 #include <tools/time.hxx>
31 #include <tools/stream.hxx>
32 
33 #include <unotools/configmgr.hxx>
35 
36 #include <vcl/toolkit/dialog.hxx>
37 #include <vcl/dialoghelper.hxx>
38 #include <vcl/lok.hxx>
39 #include <vcl/floatwin.hxx>
40 #include <vcl/settings.hxx>
41 #include <vcl/keycod.hxx>
42 #include <vcl/event.hxx>
43 #include <vcl/vclevent.hxx>
44 #include <vcl/virdev.hxx>
45 #include <vcl/wrkwin.hxx>
46 #include <vcl/svapp.hxx>
47 #include <vcl/cvtgrf.hxx>
48 #include <vcl/toolkit/unowrap.hxx>
49 #include <vcl/timer.hxx>
50 #include <vcl/scheduler.hxx>
51 #if HAVE_FEATURE_OPENGL
53 #endif
54 #include <vcl/skia/SkiaHelper.hxx>
55 
56 #include <salinst.hxx>
57 #include <salframe.hxx>
58 #include <salsys.hxx>
59 #include <svdata.hxx>
61 #include <window.h>
62 #include <accmgr.hxx>
63 #include <strings.hrc>
64 #include <strings.hxx>
65 #if OSL_DEBUG_LEVEL > 0
66 #include <schedulerimpl.hxx>
67 #endif
68 
69 #include <com/sun/star/uno/Reference.h>
70 #include <com/sun/star/awt/XToolkit.hpp>
71 #include <comphelper/lok.hxx>
73 #include <osl/process.h>
74 
75 #include <cassert>
76 #include <utility>
77 #include <thread>
78 
79 using namespace ::com::sun::star;
80 using namespace ::com::sun::star::uno;
81 
82 namespace {
83 void InitSettings(ImplSVData* pSVData);
84 }
85 
86 // keycodes handled internally by VCL
87 vcl::KeyCode const ReservedKeys[]
88 {
89  vcl::KeyCode(KEY_F1,0) ,
96  vcl::KeyCode(KEY_F6,0) ,
101 #ifdef UNX
102  ,
114 #endif
115 };
116 
117 extern "C" {
118  typedef UnoWrapperBase* (*FN_TkCreateUnoWrapper)();
119 }
120 
122 {
129 
130  ImplPostEventData(VclEventId nEvent, vcl::Window* pWin, const KeyEvent& rKeyEvent)
131  : mnEvent(nEvent)
132  , mpWin(pWin)
133  , mnEventId(nullptr)
134  , maKeyEvent(rKeyEvent)
135  {}
136  ImplPostEventData(VclEventId nEvent, vcl::Window* pWin, const MouseEvent& rMouseEvent)
137  : mnEvent(nEvent)
138  , mpWin(pWin)
139  , mnEventId(nullptr)
140  , maMouseEvent(rMouseEvent)
141  {}
142  ImplPostEventData(VclEventId nEvent, vcl::Window* pWin, const GestureEvent& rGestureEvent)
143  : mnEvent(nEvent)
144  , mpWin(pWin)
145  , mnEventId(nullptr)
146  , maGestureEvent(rGestureEvent)
147  {}
148 };
149 
151 {
152  ImplSVData* pSVData = ImplGetSVData();
153  if ( !pSVData )
154  return nullptr;
155  return pSVData->mpApp;
156 }
157 
159 {
160  // useful for themes at least, perhaps extensions too
161  OUString aVar("LIBO_VERSION"), aValue(LIBO_VERSION_DOTTED);
162  osl_setEnvironment(aVar.pData, aValue.pData);
163 
164  ImplGetSVData()->mpApp = this;
165 }
166 
168 {
170  ImplGetSVData()->mpApp = nullptr;
171 }
172 
174 {
175  SAL_WARN("vcl", "Application is a base class and should be overridden.");
176  return EXIT_SUCCESS;
177 }
178 
180 {
182 
183  // call the close handler of the application window
184  if ( pAppWin )
185  return pAppWin->Close();
186  else
187  return true;
188 }
189 
191 {
192 }
193 
195 {
196 }
197 
199 {
200 }
201 
203 {
204 }
205 
207 {
208  return static_cast<sal_uInt16>(osl_getCommandArgCount());
209 }
210 
212 {
213  OUString aParam;
214  osl_getCommandArg( nParam, &aParam.pData );
215  return aParam;
216 }
217 
219 {
220  ImplSVData* pSVData = ImplGetSVData();
221  SAL_WARN_IF( !pSVData->maAppData.mxAppFileName, "vcl", "AppFileName should be set to something after SVMain!" );
222  if ( pSVData->maAppData.mxAppFileName )
223  return *pSVData->maAppData.mxAppFileName;
224 
225  /*
226  * provide a fallback for people without initialized vcl here (like setup
227  * in responsefile mode)
228  */
229  OUString aAppFileName;
230  OUString aExeFileName;
231  osl_getExecutableFile(&aExeFileName.pData);
232 
233  // convert path to native file format
234  osl::FileBase::getSystemPathFromFileURL(aExeFileName, aAppFileName);
235 
236  return aAppFileName;
237 }
238 
240 {
241  switch ( nCategory )
242  {
243  // System has precedence (so do nothing)
246  break;
247 
248 #ifdef DBG_UTIL
250  Abort("Resource not loaded");
251  break;
252  default:
253  Abort("Unknown Error");
254  break;
255 #else
256  default:
257  Abort(OUString());
258  break;
259 #endif
260  }
261 }
262 
263 void Application::Abort( const OUString& rErrorText )
264 {
265  //HACK: Dump core iff --norestore command line argument is given (assuming
266  // this process is run by developers who are interested in cores, vs. end
267  // users who are not):
268 #if OSL_DEBUG_LEVEL > 0
269  bool dumpCore = true;
270 #else
271  bool dumpCore = false;
272  sal_uInt16 n = GetCommandLineParamCount();
273  for (sal_uInt16 i = 0; i != n; ++i) {
274  if (GetCommandLineParam(i) == "--norestore") {
275  dumpCore = true;
276  break;
277  }
278  }
279 #endif
280 
281  SalAbort( rErrorText, dumpCore );
282 }
283 
285 {
286  return SAL_N_ELEMENTS(ReservedKeys);
287 }
288 
290 {
291  if( i >= GetReservedKeyCodeCount() )
292  return nullptr;
293  else
294  return &ReservedKeys[i];
295 }
296 
297 IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplEndAllPopupsMsg, void*, void )
298 {
299  ImplSVData* pSVData = ImplGetSVData();
300  while (pSVData->mpWinData->mpFirstFloat)
302 }
303 
304 IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplEndAllDialogsMsg, void*, void )
305 {
307  while (pAppWindow)
308  {
309  vcl::EndAllDialogs(pAppWindow);
310  pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
311  }
312 }
313 
315 {
316  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplEndAllDialogsMsg ) );
317 }
318 
320 {
321  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplEndAllPopupsMsg ) );
322 }
323 
324 
325 namespace
326 {
327  VclPtr<vcl::Window> GetEventWindow()
328  {
330  while (xWin)
331  {
332  if (xWin->IsVisible())
333  break;
334  xWin.reset(Application::GetNextTopLevelWindow(xWin));
335  }
336  return xWin;
337  }
338 
339  bool InjectKeyEvent(SvStream& rStream)
340  {
341  VclPtr<vcl::Window> xWin(GetEventWindow());
342  if (!xWin)
343  return false;
344 
345  // skip the first available cycle and insert on the next one when we
346  // are trying the initial event, flagged by a triggered but undeleted
347  // mpEventTestingIdle
348  ImplSVData* pSVData = ImplGetSVData();
349  if (pSVData->maAppData.mpEventTestingIdle)
350  {
351  delete pSVData->maAppData.mpEventTestingIdle;
352  pSVData->maAppData.mpEventTestingIdle = nullptr;
353  return false;
354  }
355 
356  sal_uInt16 nCode, nCharCode;
357  rStream.ReadUInt16(nCode);
358  rStream.ReadUInt16(nCharCode);
359  if (!rStream.good())
360  return false;
361 
362  KeyEvent aVCLKeyEvt(nCharCode, nCode);
363  Application::PostKeyEvent(VclEventId::WindowKeyInput, xWin.get(), &aVCLKeyEvt);
364  Application::PostKeyEvent(VclEventId::WindowKeyUp, xWin.get(), &aVCLKeyEvt);
365  return true;
366  }
367 
368  void CloseDialogsAndQuit()
369  {
372  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplPrepareExitMsg ) );
373  }
374 }
375 
376 IMPL_LINK_NOARG(ImplSVAppData, VclEventTestingHdl, Timer *, void)
377 {
378  if (Application::AnyInput())
379  {
380  mpEventTestingIdle->Start();
381  }
382  else
383  {
384  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplVclEventTestingHdl ) );
385  }
386 }
387 
388 IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplVclEventTestingHdl, void*, void )
389 {
390  ImplSVData* pSVData = ImplGetSVData();
391  SAL_INFO("vcl.eventtesting", "EventTestLimit is " << pSVData->maAppData.mnEventTestLimit);
392  if (pSVData->maAppData.mnEventTestLimit == 0)
393  {
394  delete pSVData->maAppData.mpEventTestInput;
395  SAL_INFO("vcl.eventtesting", "Event Limit reached, exiting" << pSVData->maAppData.mnEventTestLimit);
396  CloseDialogsAndQuit();
397  }
398  else
399  {
400  if (InjectKeyEvent(*pSVData->maAppData.mpEventTestInput))
401  --pSVData->maAppData.mnEventTestLimit;
402  if (!pSVData->maAppData.mpEventTestInput->good())
403  {
404  SAL_INFO("vcl.eventtesting", "Event Input exhausted, exit next cycle");
405  pSVData->maAppData.mnEventTestLimit = 0;
406  }
407  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplVclEventTestingHdl ) );
408  }
409 }
410 
411 IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplPrepareExitMsg, void*, void )
412 {
413  //now close top level frames
414  (void)GetpApp()->QueryExit();
415 }
416 
418 {
419  ImplSVData* pSVData = ImplGetSVData();
420  pSVData->maAppData.mbInAppExecute = true;
421  pSVData->maAppData.mbAppQuit = false;
422 
424  {
425  pSVData->maAppData.mnEventTestLimit = 50;
426  pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting");
427  pSVData->maAppData.mpEventTestingIdle->SetInvokeHandler(LINK(&(pSVData->maAppData), ImplSVAppData, VclEventTestingHdl));
429  pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ);
430  pSVData->maAppData.mpEventTestingIdle->Start();
431  }
432 
433  while ( !pSVData->maAppData.mbAppQuit )
435 
436  pSVData->maAppData.mbInAppExecute = false;
437 
438  GetpApp()->Shutdown();
439 }
440 
441 static bool ImplYield(bool i_bWait, bool i_bAllEvents)
442 {
443  ImplSVData* pSVData = ImplGetSVData();
444 
445  SAL_INFO("vcl.schedule", "Enter ImplYield: " << (i_bWait ? "wait" : "no wait") <<
446  ": " << (i_bAllEvents ? "all events" : "one event"));
447 
448  // there's a data race here on WNT only because ImplYield may be
449  // called without SolarMutex; but the only remaining use of mnDispatchLevel
450  // is in OSX specific code
451  pSVData->maAppData.mnDispatchLevel++;
452 
453  // do not wait for events if application was already quit; in that
454  // case only dispatch events already available
455  bool bProcessedEvent = pSVData->mpDefInst->DoYield(
456  i_bWait && !pSVData->maAppData.mbAppQuit, i_bAllEvents );
457 
458  pSVData->maAppData.mnDispatchLevel--;
459 
460  DBG_TESTSOLARMUTEX(); // must be locked on return from Yield
461 
462  SAL_INFO("vcl.schedule", "Leave ImplYield with return " << bProcessedEvent );
463  return bProcessedEvent;
464 }
465 
466 bool Application::Reschedule( bool i_bAllEvents )
467 {
468  return ImplYield(false, i_bAllEvents);
469 }
470 
472 {
473  int nSanity = 1;
474  while( Application::Reschedule( true ) )
475  {
476  if (0 == ++nSanity % 1000)
477  {
478  SAL_WARN("vcl.schedule", "ProcessEventsToIdle: " << nSanity);
479  }
480  }
481 #if OSL_DEBUG_LEVEL > 0
482  // If we yield from a non-main thread we just can guarantee that all idle
483  // events were processed at some point, but our check can't prevent further
484  // processing in the main thread, which may add new events, so skip it.
485  const ImplSVData* pSVData = ImplGetSVData();
486  if ( !pSVData->mpDefInst->IsMainThread() )
487  return;
488  for (int nTaskPriority = 0; nTaskPriority < PRIO_COUNT; ++nTaskPriority)
489  {
490  const ImplSchedulerData* pSchedulerData = pSVData->maSchedCtx.mpFirstSchedulerData[nTaskPriority];
491  while (pSchedulerData)
492  {
493  if (pSchedulerData->mpTask && !pSchedulerData->mbInScheduler)
494  {
495  Idle *pIdle = dynamic_cast<Idle*>(pSchedulerData->mpTask);
496  if (pIdle && pIdle->IsActive())
497  {
498  SAL_WARN("vcl.schedule", "Unprocessed Idle: "
499  << pIdle << " " << pIdle->GetDebugName());
500  }
501  }
502  pSchedulerData = pSchedulerData->mpNext;
503  }
504  }
505 #endif
506 }
507 
508 extern "C" {
510 SAL_DLLPUBLIC_EXPORT void unit_lok_process_events_to_idle()
511 {
512  const SolarMutexGuard aGuard;
514 }
515 }
516 
518 {
519  ImplYield(true, false);
520 }
521 
522 IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplQuitMsg, void*, void )
523 {
524  assert(ImplGetSVData()->maAppData.mbAppQuit);
525 }
526 
528 {
530  Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplQuitMsg ) );
531 }
532 
534 {
535  ImplSVData* pSVData = ImplGetSVData();
536  return *(pSVData->mpDefInst->GetYieldMutex());
537 }
538 
540 {
541  return ImplGetSVData()->mnMainThreadId == osl::Thread::getCurrentIdentifier();
542 }
543 
545 {
546  ImplSVData* pSVData = ImplGetSVData();
547  return pSVData->mpDefInst->ReleaseYieldMutexAll();
548 }
549 
550 void Application::AcquireSolarMutex( sal_uInt32 nCount )
551 {
552  ImplSVData* pSVData = ImplGetSVData();
553  pSVData->mpDefInst->AcquireYieldMutex( nCount );
554 }
555 
557 {
558  ImplSVData* pSVData = ImplGetSVData();
559  return pSVData && pSVData->maAppData.mbInAppMain;
560 }
561 
563 {
565 }
566 
568 {
569  return (ImplGetSVData()->maAppData.mnModalMode != 0);
570 }
571 
573 {
575 }
576 
578 {
579  return ImplGetSVData()->mpDefInst->AnyInput( nType );
580 }
581 
583 {
584  return (tools::Time::GetSystemTicks()-ImplGetSVData()->maAppData.mnLastInputTime);
585 }
586 
588 {
589  ImplSVData* pSVData = ImplGetSVData();
590 
591  // If mouse was captured, or if in tracking- or in select-mode of a floatingwindow (e.g. menus
592  // or pulldown toolboxes) another window should be created
593  // D&D active !!!
594  return pSVData->mpWinData->mpCaptureWin || pSVData->mpWinData->mpTrackWin
595  || pSVData->mpWinData->mpFirstFloat || nImplSysDialog;
596 }
597 
599 {
600 }
601 
603 {
605  if( ! pWindow )
606  pWindow = ImplGetDefaultWindow();
607  if( pWindow )
608  {
609  ImplSVData* pSVData = ImplGetSVData();
610  if ( !pSVData->maAppData.mbSettingsInit )
611  {
612  // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
613  pWindow->ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings );
614  pSVData->maAppData.mbSettingsInit = true;
615  }
616  // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
617  pWindow->ImplUpdateGlobalSettings( rSettings, false );
618  }
619 }
620 
621 void Application::SetSettings( const AllSettings& rSettings )
622 {
623  const SolarMutexGuard aGuard;
624 
625  ImplSVData* pSVData = ImplGetSVData();
626  if ( !pSVData->maAppData.mpSettings )
627  {
628  InitSettings(pSVData);
629  *pSVData->maAppData.mpSettings = rSettings;
630  }
631  else
632  {
633  AllSettings aOldSettings = *pSVData->maAppData.mpSettings;
634  if (aOldSettings.GetUILanguageTag().getLanguageType() != rSettings.GetUILanguageTag().getLanguageType() &&
635  pSVData->mbResLocaleSet)
636  {
637  pSVData->mbResLocaleSet = false;
638  }
639  *pSVData->maAppData.mpSettings = rSettings;
640  AllSettingsFlags nChangeFlags = aOldSettings.GetChangeFlags( *pSVData->maAppData.mpSettings );
641  if ( bool(nChangeFlags) )
642  {
643  DataChangedEvent aDCEvt( DataChangedEventType::SETTINGS, &aOldSettings, nChangeFlags );
644 
645  // notify data change handler
647 
648  // Update all windows
649  vcl::Window* pFirstFrame = pSVData->maFrameData.mpFirstFrame;
650  // Reset data that needs to be re-calculated
651  long nOldDPIX = 0;
652  long nOldDPIY = 0;
653  if ( pFirstFrame )
654  {
655  nOldDPIX = pFirstFrame->GetDPIX();
656  nOldDPIY = pFirstFrame->GetDPIY();
658  }
659  vcl::Window* pFrame = pFirstFrame;
660  while ( pFrame )
661  {
662  // call UpdateSettings from ClientWindow in order to prevent updating data twice
663  vcl::Window* pClientWin = pFrame;
664  while ( pClientWin->ImplGetClientWindow() )
665  pClientWin = pClientWin->ImplGetClientWindow();
666  pClientWin->UpdateSettings( rSettings, true );
667 
668  vcl::Window* pTempWin = pFrame->mpWindowImpl->mpFrameData->mpFirstOverlap;
669  while ( pTempWin )
670  {
671  // call UpdateSettings from ClientWindow in order to prevent updating data twice
672  pClientWin = pTempWin;
673  while ( pClientWin->ImplGetClientWindow() )
674  pClientWin = pClientWin->ImplGetClientWindow();
675  pClientWin->UpdateSettings( rSettings, true );
676  pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
677  }
678 
679  pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame;
680  }
681 
682  // if DPI resolution for screen output was changed set the new resolution for all
683  // screen compatible VirDev's
684  pFirstFrame = pSVData->maFrameData.mpFirstFrame;
685  if ( pFirstFrame )
686  {
687  if ( (pFirstFrame->GetDPIX() != nOldDPIX) ||
688  (pFirstFrame->GetDPIY() != nOldDPIY) )
689  {
690  VirtualDevice* pVirDev = pSVData->maGDIData.mpFirstVirDev;
691  while ( pVirDev )
692  {
693  if ( pVirDev->mbScreenComp &&
694  (pVirDev->GetDPIX() == nOldDPIX) &&
695  (pVirDev->GetDPIY() == nOldDPIY) )
696  {
697  pVirDev->SetDPIX( pFirstFrame->GetDPIX() );
698  pVirDev->SetDPIY( pFirstFrame->GetDPIY() );
699  if ( pVirDev->IsMapModeEnabled() )
700  {
701  MapMode aMapMode = pVirDev->GetMapMode();
702  pVirDev->SetMapMode();
703  pVirDev->SetMapMode( aMapMode );
704  }
705  }
706 
707  pVirDev = pVirDev->mpNext;
708  }
709  }
710  }
711  }
712  }
713 }
714 
716 {
717  ImplSVData* pSVData = ImplGetSVData();
718  if ( !pSVData->maAppData.mpSettings )
719  {
720  InitSettings(pSVData);
721  }
722 
723  return *(pSVData->maAppData.mpSettings);
724 }
725 
726 namespace {
727 
728 void InitSettings(ImplSVData* pSVData)
729 {
730  assert(!pSVData->maAppData.mpSettings && "initialization should not happen twice!");
731 
732  pSVData->maAppData.mpSettings.reset(new AllSettings());
734  {
736  pSVData->maAppData.mpSettings->GetSysLocale().GetOptions().AddListener( pSVData->maAppData.mpCfgListener );
737  }
738 }
739 
740 }
741 
743 {
744  ImplSVData* pSVData = ImplGetSVData();
745  vcl::Window* pFrame = pSVData->maFrameData.mpFirstFrame;
746  while ( pFrame )
747  {
748  pFrame->NotifyAllChildren( rDCEvt );
749 
750  vcl::Window* pSysWin = pFrame->mpWindowImpl->mpFrameData->mpFirstOverlap;
751  while ( pSysWin )
752  {
753  pSysWin->NotifyAllChildren( rDCEvt );
754  pSysWin = pSysWin->mpWindowImpl->mpNextOverlap;
755  }
756 
757  pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame;
758  }
759 }
760 
762 {
763  ImplSVData* pSVData = ImplGetSVData();
765 
766  pSVData->maAppData.maEventListeners.Call( aEvent );
767 }
768 
770 {
771  ImplSVData* pSVData = ImplGetSVData();
772  pSVData->maAppData.maEventListeners.Call( rEvent );
773 }
774 
776 {
777  ImplSVData* pSVData = ImplGetSVData();
778  pSVData->maAppData.maEventListeners.addListener( rEventListener );
779 }
780 
782 {
783  ImplSVData* pSVData = ImplGetSVData();
784  pSVData->maAppData.maEventListeners.removeListener( rEventListener );
785 }
786 
788 {
789  ImplSVData* pSVData = ImplGetSVData();
790  pSVData->maAppData.maKeyListeners.push_back( rKeyListener );
791 }
792 
794 {
795  ImplSVData* pSVData = ImplGetSVData();
796  auto & rVec = pSVData->maAppData.maKeyListeners;
797  rVec.erase( std::remove(rVec.begin(), rVec.end(), rKeyListener ), rVec.end() );
798 }
799 
800 bool Application::HandleKey( VclEventId nEvent, vcl::Window *pWin, KeyEvent* pKeyEvent )
801 {
802  // let listeners process the key event
803  VclWindowEvent aEvent( pWin, nEvent, static_cast<void *>(pKeyEvent) );
804 
805  ImplSVData* pSVData = ImplGetSVData();
806 
807  if ( pSVData->maAppData.maKeyListeners.empty() )
808  return false;
809 
810  bool bProcessed = false;
811  // Copy the list, because this can be destroyed when calling a Link...
812  std::vector<Link<VclWindowEvent&,bool>> aCopy( pSVData->maAppData.maKeyListeners );
813  for ( const Link<VclWindowEvent&,bool>& rLink : aCopy )
814  {
815  if( rLink.Call( aEvent ) )
816  {
817  bProcessed = true;
818  break;
819  }
820  }
821  return bProcessed;
822 }
823 
825 {
826  const SolarMutexGuard aGuard;
827  ImplSVEvent * nEventId = nullptr;
828 
829  if( pWin && pKeyEvent )
830  {
831  std::unique_ptr<ImplPostEventData> pPostEventData(new ImplPostEventData( nEvent, pWin, *pKeyEvent ));
832 
833  nEventId = PostUserEvent(
834  LINK( nullptr, Application, PostEventHandler ),
835  pPostEventData.get() );
836 
837  if( nEventId )
838  {
839  pPostEventData->mnEventId = nEventId;
840  ImplGetSVData()->maAppData.maPostedEventList.emplace_back( pWin, pPostEventData.release() );
841  }
842  }
843 
844  return nEventId;
845 }
846 
848 {
849  const SolarMutexGuard aGuard;
850  ImplSVEvent * nEventId = nullptr;
851 
852  if (pWin && pGestureEvent)
853  {
854  Point aTransformedPosition(pGestureEvent->mnX, pGestureEvent->mnY);
855 
856  aTransformedPosition.AdjustX(pWin->GetOutOffXPixel());
857  aTransformedPosition.AdjustY(pWin->GetOutOffYPixel());
858 
859  const GestureEvent aGestureEvent(
860  sal_Int32(aTransformedPosition.X()),
861  sal_Int32(aTransformedPosition.Y()),
862  pGestureEvent->meEventType,
863  pGestureEvent->mnOffset,
864  pGestureEvent->meOrientation
865  );
866 
867  std::unique_ptr<ImplPostEventData> pPostEventData(new ImplPostEventData(nEvent, pWin, aGestureEvent));
868 
869  nEventId = PostUserEvent(
870  LINK( nullptr, Application, PostEventHandler ),
871  pPostEventData.get());
872 
873  if (nEventId)
874  {
875  pPostEventData->mnEventId = nEventId;
876  ImplGetSVData()->maAppData.maPostedEventList.emplace_back(pWin, pPostEventData.release());
877  }
878  }
879 
880  return nEventId;
881 }
882 
884 {
885  const SolarMutexGuard aGuard;
886  ImplSVEvent * nEventId = nullptr;
887 
888  if( pWin && pMouseEvent )
889  {
890  Point aTransformedPos( pMouseEvent->GetPosPixel() );
891 
892  // LOK uses (0, 0) as the origin of all windows; don't offset.
894  {
895  aTransformedPos.AdjustX(pWin->GetOutOffXPixel());
896  aTransformedPos.AdjustY(pWin->GetOutOffYPixel());
897  }
898 
899  const MouseEvent aTransformedEvent( aTransformedPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(),
900  pMouseEvent->GetButtons(), pMouseEvent->GetModifier() );
901 
902  std::unique_ptr<ImplPostEventData> pPostEventData(new ImplPostEventData( nEvent, pWin, aTransformedEvent ));
903 
904  nEventId = PostUserEvent(
905  LINK( nullptr, Application, PostEventHandler ),
906  pPostEventData.get() );
907 
908  if( nEventId )
909  {
910  pPostEventData->mnEventId = nEventId;
911  ImplGetSVData()->maAppData.maPostedEventList.emplace_back( pWin, pPostEventData.release() );
912  }
913  }
914 
915  return nEventId;
916 }
917 
918 
919 IMPL_STATIC_LINK( Application, PostEventHandler, void*, pCallData, void )
920 {
921  const SolarMutexGuard aGuard;
922  ImplPostEventData* pData = static_cast< ImplPostEventData * >( pCallData );
923  const void* pEventData;
924  SalEvent nEvent;
925  ImplSVEvent * const nEventId = pData->mnEventId;
926 
927  switch( pData->mnEvent )
928  {
931  pEventData = &pData->maMouseEvent;
932  break;
933 
936  pEventData = &pData->maMouseEvent;
937  break;
938 
941  pEventData = &pData->maMouseEvent;
942  break;
943 
946  pEventData = &pData->maKeyEvent;
947  break;
948 
950  nEvent = SalEvent::ExternalKeyUp;
951  pEventData = &pData->maKeyEvent;
952  break;
953 
955  nEvent = SalEvent::ExternalGesture;
956  pEventData = &pData->maGestureEvent;
957  break;
958 
959  default:
960  nEvent = SalEvent::NONE;
961  pEventData = nullptr;
962  break;
963  }
964 
965  if( pData->mpWin && pData->mpWin->mpWindowImpl->mpFrameWindow && pEventData )
966  ImplWindowFrameProc( pData->mpWin->mpWindowImpl->mpFrameWindow.get(), nEvent, pEventData );
967 
968  // remove this event from list of posted events, watch for destruction of internal data
969  auto svdata = ImplGetSVData();
970  ::std::vector< ImplPostEventPair >::iterator aIter( svdata->maAppData.maPostedEventList.begin() );
971 
972  while( aIter != svdata->maAppData.maPostedEventList.end() )
973  {
974  if( nEventId == (*aIter).second->mnEventId )
975  {
976  delete (*aIter).second;
977  aIter = svdata->maAppData.maPostedEventList.erase( aIter );
978  }
979  else
980  ++aIter;
981  }
982 }
983 
985 {
986  const SolarMutexGuard aGuard;
987 
988  // remove all events for specific window, watch for destruction of internal data
989  auto svdata = ImplGetSVData();
990  ::std::vector< ImplPostEventPair >::iterator aIter( svdata->maAppData.maPostedEventList.begin() );
991 
992  while( aIter != svdata->maAppData.maPostedEventList.end() )
993  {
994  if( pWin == (*aIter).first )
995  {
996  if( (*aIter).second->mnEventId )
997  RemoveUserEvent( (*aIter).second->mnEventId );
998 
999  delete (*aIter).second;
1000  aIter = svdata->maAppData.maPostedEventList.erase( aIter );
1001  }
1002  else
1003  ++aIter;
1004  }
1005 }
1006 
1008  bool bReferenceLink )
1009 {
1010  vcl::Window* pDefWindow = ImplGetDefaultWindow();
1011  if ( pDefWindow == nullptr )
1012  return nullptr;
1013 
1014  std::unique_ptr<ImplSVEvent> pSVEvent(new ImplSVEvent);
1015  pSVEvent->mpData = pCaller;
1016  pSVEvent->maLink = rLink;
1017  pSVEvent->mpWindow = nullptr;
1018  pSVEvent->mbCall = true;
1019  if (bReferenceLink)
1020  {
1021  SolarMutexGuard aGuard;
1022  // Double check that this is indeed a vcl::Window instance.
1023  assert(dynamic_cast<vcl::Window *>(
1024  static_cast<OutputDevice *>(rLink.GetInstance())) ==
1025  static_cast<vcl::Window *>(rLink.GetInstance()));
1026  pSVEvent->mpInstanceRef = static_cast<vcl::Window *>(rLink.GetInstance());
1027  }
1028 
1029  auto pTmpEvent = pSVEvent.get();
1030  if (!pDefWindow->ImplGetFrame()->PostEvent( std::move(pSVEvent) ))
1031  return nullptr;
1032  return pTmpEvent;
1033 }
1034 
1036 {
1037  if(nUserEvent)
1038  {
1039  SAL_WARN_IF( nUserEvent->mpWindow, "vcl",
1040  "Application::RemoveUserEvent(): Event is send to a window" );
1041  SAL_WARN_IF( !nUserEvent->mbCall, "vcl",
1042  "Application::RemoveUserEvent(): Event is already removed" );
1043 
1044  nUserEvent->mpWindow.clear();
1045  nUserEvent->mpInstanceRef.clear();
1046  nUserEvent->mbCall = false;
1047  }
1048 }
1049 
1051 {
1053 }
1054 
1056 {
1057  return ImplGetSVData()->mpWinData->mpFocusWin;
1058 }
1059 
1061 {
1062  return ImplGetDefaultWindow();
1063 }
1064 
1066 {
1067  ImplSVData* pSVData = ImplGetSVData();
1068  return pSVData->maFrameData.mpFirstFrame;
1069 }
1070 
1072 {
1073  return pWindow->mpWindowImpl->mpFrameData->mpNextFrame;
1074 }
1075 
1077 {
1078  long nRet = 0;
1079  ImplSVData* pSVData = ImplGetSVData();
1080  vcl::Window *pWin = pSVData ? pSVData->maFrameData.mpFirstFrame.get() : nullptr;
1081  while( pWin )
1082  {
1083  if( pWin->ImplGetWindow()->IsTopWindow() )
1084  nRet++;
1085  pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
1086  }
1087  return nRet;
1088 }
1089 
1091 {
1092  long nIdx = 0;
1093  ImplSVData* pSVData = ImplGetSVData();
1094  vcl::Window *pWin = pSVData ? pSVData->maFrameData.mpFirstFrame.get() : nullptr;
1095  while( pWin )
1096  {
1097  if( pWin->ImplGetWindow()->IsTopWindow() )
1098  {
1099  if( nIdx == nIndex )
1100  return pWin->ImplGetWindow();
1101  else
1102  nIdx++;
1103  }
1104  pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
1105  }
1106  return nullptr;
1107 }
1108 
1110 {
1112  while( pWin )
1113  {
1114  if( pWin->IsTopWindow() )
1115  return pWin;
1116  pWin = pWin->mpWindowImpl->mpParent;
1117  }
1118  return nullptr;
1119 }
1120 
1121 void Application::SetAppName( const OUString& rUniqueName )
1122 {
1123  ImplSVData* pSVData = ImplGetSVData();
1124  pSVData->maAppData.mxAppName = rUniqueName;
1125 }
1126 
1128 {
1129  ImplSVData* pSVData = ImplGetSVData();
1130  if ( pSVData->maAppData.mxAppName )
1131  return *(pSVData->maAppData.mxAppName);
1132  else
1133  return OUString();
1134 }
1135 
1136 enum {hwAll=0, hwEnv=1, hwUI=2};
1137 
1138 OUString Application::GetHWOSConfInfo(const int bSelection)
1139 {
1140  ImplSVData* pSVData = ImplGetSVData();
1141  OUStringBuffer aDetails;
1142 
1143  const auto appendDetails = [&aDetails](const OUStringLiteral& sep, auto&& val) {
1144  if (!aDetails.isEmpty() && sep.getLength())
1145  aDetails.append(sep);
1146  aDetails.append(std::move(val));
1147  };
1148 
1149  if (bSelection != hwUI) {
1150  appendDetails("; ", VclResId(SV_APP_CPUTHREADS)
1151  + OUString::number(std::thread::hardware_concurrency()));
1152 
1153  OUString aVersion;
1154  if ( pSVData && pSVData->mpDefInst )
1155  aVersion = pSVData->mpDefInst->getOSVersion();
1156  else
1157  aVersion = "-";
1158 
1159  appendDetails("; ", VclResId(SV_APP_OSVERSION) + aVersion);
1160  }
1161 
1162  if (bSelection != hwEnv) {
1163  appendDetails("; ", VclResId(SV_APP_UIRENDER));
1164 #if HAVE_FEATURE_SKIA
1166  {
1167  switch(SkiaHelper::renderMethodToUse())
1168  {
1169  case SkiaHelper::RenderVulkan:
1170  appendDetails("", VclResId(SV_APP_SKIA_VULKAN));
1171  break;
1172  case SkiaHelper::RenderRaster:
1173  appendDetails("", VclResId(SV_APP_SKIA_RASTER));
1174  break;
1175  }
1176  }
1177  else
1178 #endif
1179 #if HAVE_FEATURE_OPENGL
1181  appendDetails("", VclResId(SV_APP_GL));
1182  else
1183 #endif
1184  appendDetails("", VclResId(SV_APP_DEFAULT));
1185 
1186 #if (defined LINUX || defined _WIN32 || defined MACOSX)
1187  appendDetails("; ", SV_APP_VCLBACKEND + GetToolkitName());
1188 #endif
1189  }
1190 
1191  return aDetails.makeStringAndClear();
1192 }
1193 
1194 void Application::SetDisplayName( const OUString& rName )
1195 {
1196  ImplSVData* pSVData = ImplGetSVData();
1197  pSVData->maAppData.mxDisplayName = rName;
1198 }
1199 
1201 {
1202  ImplSVData* pSVData = ImplGetSVData();
1203  if ( pSVData->maAppData.mxDisplayName )
1204  return *(pSVData->maAppData.mxDisplayName);
1205  else if (pSVData->maFrameData.mpAppWin)
1206  return pSVData->maFrameData.mpAppWin->GetText();
1207  else
1208  return OUString();
1209 }
1210 
1212 {
1213  SalSystem* pSys = ImplGetSalSystem();
1214  return pSys ? pSys->GetDisplayScreenCount() : 0;
1215 }
1216 
1218 {
1219  SalSystem* pSys = ImplGetSalSystem();
1220  return pSys == nullptr || pSys->IsUnifiedDisplay();
1221 }
1222 
1224 {
1225  SalSystem* pSys = ImplGetSalSystem();
1226  return pSys ? pSys->GetDisplayBuiltInScreen() : 0;
1227 }
1228 
1230 {
1231  // This is really unpleasant, in theory we could have multiple
1232  // external displays etc.
1233  int nExternal(0);
1234  switch (GetDisplayBuiltInScreen())
1235  {
1236  case 0:
1237  nExternal = 1;
1238  break;
1239  case 1:
1240  nExternal = 0;
1241  break;
1242  default:
1243  // When the built-in display is neither 0 nor 1
1244  // then place the full-screen presentation on the
1245  // first available screen.
1246  nExternal = 0;
1247  break;
1248  }
1249  return nExternal;
1250 }
1251 
1253 {
1254  SalSystem* pSys = ImplGetSalSystem();
1255  if (!pSys)
1256  {
1257  SAL_WARN("vcl", "Requesting screen size/pos for screen #" << nScreen << " failed");
1258  assert(false);
1259  return tools::Rectangle();
1260  }
1261  tools::Rectangle aRect = pSys->GetDisplayScreenPosSizePixel(nScreen);
1262  if (aRect.getHeight() == 0)
1263  SAL_WARN("vcl", "Requesting screen size/pos for screen #" << nScreen << " returned 0 height.");
1264  return aRect;
1265 }
1266 
1267 namespace {
1268 unsigned long calcDistSquare( const Point& i_rPoint, const tools::Rectangle& i_rRect )
1269 {
1270  const Point aRectCenter( (i_rRect.Left() + i_rRect.Right())/2,
1271  (i_rRect.Top() + i_rRect.Bottom())/ 2 );
1272  const long nDX = aRectCenter.X() - i_rPoint.X();
1273  const long nDY = aRectCenter.Y() - i_rPoint.Y();
1274  return nDX*nDX + nDY*nDY;
1275 }
1276 }
1277 
1278 unsigned int Application::GetBestScreen( const tools::Rectangle& i_rRect )
1279 {
1280  if( !IsUnifiedDisplay() )
1281  return GetDisplayBuiltInScreen();
1282 
1283  const unsigned int nScreens = GetScreenCount();
1284  unsigned int nBestMatchScreen = 0;
1285  unsigned long nOverlap = 0;
1286  for( unsigned int i = 0; i < nScreens; i++ )
1287  {
1288  const tools::Rectangle aCurScreenRect( GetScreenPosSizePixel( i ) );
1289  // if a screen contains the rectangle completely it is obviously the best screen
1290  if( aCurScreenRect.IsInside( i_rRect ) )
1291  return i;
1292  // next the screen which contains most of the area of the rect is the best
1293  tools::Rectangle aIntersection( aCurScreenRect.GetIntersection( i_rRect ) );
1294  if( ! aIntersection.IsEmpty() )
1295  {
1296  const unsigned long nCurOverlap( aIntersection.GetWidth() * aIntersection.GetHeight() );
1297  if( nCurOverlap > nOverlap )
1298  {
1299  nOverlap = nCurOverlap;
1300  nBestMatchScreen = i;
1301  }
1302  }
1303  }
1304  if( nOverlap > 0 )
1305  return nBestMatchScreen;
1306 
1307  // finally the screen which center is nearest to the rect is the best
1308  const Point aCenter( (i_rRect.Left() + i_rRect.Right())/2,
1309  (i_rRect.Top() + i_rRect.Bottom())/2 );
1310  unsigned long nDist = ULONG_MAX;
1311  for( unsigned int i = 0; i < nScreens; i++ )
1312  {
1313  const tools::Rectangle aCurScreenRect( GetScreenPosSizePixel( i ) );
1314  const unsigned long nCurDist( calcDistSquare( aCenter, aCurScreenRect ) );
1315  if( nCurDist < nDist )
1316  {
1317  nBestMatchScreen = i;
1318  nDist = nCurDist;
1319  }
1320  }
1321  return nBestMatchScreen;
1322 }
1323 
1324 bool Application::InsertAccel( Accelerator* pAccel )
1325 {
1326  ImplSVData* pSVData = ImplGetSVData();
1327 
1328  if ( !pSVData->maAppData.mpAccelMgr )
1329  pSVData->maAppData.mpAccelMgr = new ImplAccelManager();
1330  return pSVData->maAppData.mpAccelMgr->InsertAccel( pAccel );
1331 }
1332 
1333 void Application::RemoveAccel( Accelerator const * pAccel )
1334 {
1335  ImplSVData* pSVData = ImplGetSVData();
1336 
1337  if ( pSVData->maAppData.mpAccelMgr )
1338  pSVData->maAppData.mpAccelMgr->RemoveAccel( pAccel );
1339 }
1340 
1342 {
1343  ImplGetSVData()->maAppData.mpHelp = pHelp;
1344 }
1345 
1347 {
1348  ImplSVData* pSVData = ImplGetSVData();
1349  if (pSVData && pSVData->mpDefInst)
1350  pSVData->mpDefInst->updateMainThread();
1351 }
1352 
1354 {
1355  return ImplGetSVData()->maAppData.mpHelp;
1356 }
1357 
1359 {
1360  ImplSVData* pSVData = ImplGetSVData();
1361  if ( pSVData->maAppData.mxToolkitName )
1362  return *(pSVData->maAppData.mxToolkitName);
1363  else
1364  return OUString();
1365 }
1366 
1368 {
1369  ImplSVData* pSVData = ImplGetSVData();
1370  // find some useful dialog parent
1371 
1372  // always use the topmost parent of the candidate
1373  // window to avoid using dialogs or floaters
1374  // as DefDialogParent
1375 
1376  // current focus frame
1377  vcl::Window *pWin = pSVData->mpWinData->mpFocusWin;
1378  if (pWin && !pWin->IsMenuFloatingWindow())
1379  {
1380  while (pWin->mpWindowImpl && pWin->mpWindowImpl->mpParent)
1381  pWin = pWin->mpWindowImpl->mpParent;
1382 
1383  // check for corrupted window hierarchy, #122232#, may be we now crash somewhere else
1384  if (!pWin->mpWindowImpl)
1385  {
1386  OSL_FAIL( "Window hierarchy corrupted!" );
1387  pSVData->mpWinData->mpFocusWin = nullptr; // avoid further access
1388  return nullptr;
1389  }
1390 
1391  if ((pWin->mpWindowImpl->mnStyle & WB_INTROWIN) == 0)
1392  {
1393  return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1394  }
1395  }
1396 
1397  // last active application frame
1398  pWin = pSVData->maFrameData.mpActiveApplicationFrame;
1399  if (pWin)
1400  {
1401  return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1402  }
1403 
1404  // first visible top window (may be totally wrong...)
1405  pWin = pSVData->maFrameData.mpFirstFrame;
1406  while (pWin)
1407  {
1408  if( pWin->ImplGetWindow()->IsTopWindow() &&
1409  pWin->mpWindowImpl->mbReallyVisible &&
1410  (pWin->mpWindowImpl->mnStyle & WB_INTROWIN) == 0
1411  )
1412  {
1413  while( pWin->mpWindowImpl->mpParent )
1414  pWin = pWin->mpWindowImpl->mpParent;
1415  return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1416  }
1417  pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
1418  }
1419 
1420  // use the desktop
1421  return nullptr;
1422 }
1423 
1425 {
1427 }
1428 
1430 {
1432 }
1433 
1435 {
1437 }
1438 
1440 {
1442 }
1443 
1445 {
1447 }
1448 
1449 css::uno::Reference< css::awt::XToolkit > Application::GetVCLToolkit()
1450 {
1451  css::uno::Reference< css::awt::XToolkit > xT;
1452  UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper();
1453  if ( pWrapper )
1454  xT = pWrapper->GetVCLToolkit();
1455  return xT;
1456 }
1457 
1458 #ifdef DISABLE_DYNLOADING
1459 
1460 extern "C" { UnoWrapperBase* CreateUnoWrapper(); }
1461 
1462 #else
1463 
1464 extern "C" { static void thisModule() {} }
1465 
1466 #endif
1467 
1468 UnoWrapperBase* UnoWrapperBase::GetUnoWrapper( bool bCreateIfNotExist )
1469 {
1470  ImplSVData* pSVData = ImplGetSVData();
1471  static bool bAlreadyTriedToCreate = false;
1472  if ( !pSVData->mpUnoWrapper && bCreateIfNotExist && !bAlreadyTriedToCreate )
1473  {
1474 #ifndef DISABLE_DYNLOADING
1475  osl::Module aTkLib;
1476  aTkLib.loadRelative(&thisModule, TK_DLL_NAME);
1477  if (aTkLib.is())
1478  {
1479  FN_TkCreateUnoWrapper fnCreateWrapper = reinterpret_cast<FN_TkCreateUnoWrapper>(aTkLib.getFunctionSymbol("CreateUnoWrapper"));
1480  if ( fnCreateWrapper )
1481  {
1482  pSVData->mpUnoWrapper = fnCreateWrapper();
1483  }
1484  aTkLib.release();
1485  }
1486  SAL_WARN_IF( !pSVData->mpUnoWrapper, "vcl", "UnoWrapper could not be created!" );
1487 #else
1488  pSVData->mpUnoWrapper = CreateUnoWrapper();
1489 #endif
1490  bAlreadyTriedToCreate = true;
1491  }
1492  return pSVData->mpUnoWrapper;
1493 }
1494 
1495 void UnoWrapperBase::SetUnoWrapper( UnoWrapperBase* pWrapper )
1496 {
1497  ImplSVData* pSVData = ImplGetSVData();
1498  SAL_WARN_IF( pSVData->mpUnoWrapper, "vcl", "SetUnoWrapper: Wrapper already exists" );
1499  pSVData->mpUnoWrapper = pWrapper;
1500 }
1501 
1502 css::uno::Reference< css::awt::XDisplayConnection > Application::GetDisplayConnection()
1503 {
1504  ImplSVData* pSVData = ImplGetSVData();
1505 
1506  if( !pSVData->mxDisplayConnection.is() )
1507  {
1509  pSVData->mxDisplayConnection->start();
1510  }
1511 
1512  return pSVData->mxDisplayConnection.get();
1513 }
1514 
1516 {
1518 }
1519 
1521 {
1522  return GetSettings().GetLocaleDataWrapper();
1523 }
1524 
1525 void Application::EnableHeadlessMode( bool dialogsAreFatal )
1526 {
1527  DialogCancelMode eNewMode = dialogsAreFatal ? DialogCancelMode::Fatal : DialogCancelMode::Silent;
1529  assert(eOldMode == DialogCancelMode::Off || GetDialogCancelMode() == eNewMode);
1530  if (eOldMode != eNewMode)
1531  SetDialogCancelMode( eNewMode );
1532 }
1533 
1535 {
1537 }
1538 
1540 {
1542 }
1543 
1545 {
1547 }
1548 
1550 {
1551  EnableHeadlessMode(true);
1553 }
1554 
1555 static bool bEventTestingMode = false;
1556 
1558 {
1559  return bEventTestingMode;
1560 }
1561 
1563 {
1564  bEventTestingMode = true;
1565 }
1566 
1567 static bool bSafeMode = false;
1568 
1570 {
1571  return bSafeMode;
1572 }
1573 
1575 {
1576  bSafeMode = true;
1577 }
1578 
1579 void Application::ShowNativeErrorBox(const OUString& sTitle ,
1580  const OUString& sMessage)
1581 {
1583  sTitle,
1584  sMessage);
1585  if (btn != SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK) {
1586  SAL_WARN( "vcl", "ShowNativeMessageBox returned " << btn);
1587  }
1588 }
1589 
1591 {
1592  if (IsHeadlessModeEnabled())
1593  {
1594  static const OUString aNone("none");
1595  return aNone;
1596  }
1597  else
1598  return SalGetDesktopEnvironment();
1599 }
1600 
1601 void Application::AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService)
1602 {
1603  ImplSVData* pSVData = ImplGetSVData();
1604  pSVData->mpDefInst->AddToRecentDocumentList(rFileUrl, rMimeType, rDocumentService);
1605 }
1606 
1608 {
1609 // Disable MSAA bridge on UNIX
1610 #if defined UNX
1611  return true;
1612 #else
1613  bool bRet = ImplInitAccessBridge();
1614 
1615  if( !bRet )
1616  {
1617  // disable accessibility if the user chooses to continue
1618  AllSettings aSettings = Application::GetSettings();
1619  MiscSettings aMisc = aSettings.GetMiscSettings();
1620  aMisc.SetEnableATToolSupport( false );
1621  aSettings.SetMiscSettings( aMisc );
1622  Application::SetSettings( aSettings );
1623  }
1624  return bRet;
1625 #endif // !UNX
1626 }
1627 
1628 // MT: AppEvent was in oldsv.cxx, but is still needed...
1629 void Application::AppEvent( const ApplicationEvent& /*rAppEvent*/ )
1630 {
1631 }
1632 
1634 {
1635  ImplSVData* pSVData = ImplGetSVData();
1636  return pSVData->mpDefInst->hasNativeFileSelection();
1637 }
1638 
1639 Reference< ui::dialogs::XFilePicker2 >
1641 {
1642  ImplSVData* pSVData = ImplGetSVData();
1643  return pSVData->mpDefInst->createFilePicker( xSM );
1644 }
1645 
1646 Reference< ui::dialogs::XFolderPicker2 >
1648 {
1649  ImplSVData* pSVData = ImplGetSVData();
1650  return pSVData->mpDefInst->createFolderPicker( xSM );
1651 }
1652 
1654  ImplSVData * pSVData = ImplGetSVData();
1655  assert(!pSVData->maDeInitHook.IsSet());
1656  pSVData->maDeInitHook = hook;
1657  // Fake this for VCLXToolkit ctor instantiated from
1658  // postprocess/CppunitTest_services.mk:
1659  pSVData->maAppData.mbInAppMain = true;
1660 }
1661 
1662 namespace vcl::lok {
1663 
1665  LibreOfficeKitPollCallback pPollCallback,
1666  LibreOfficeKitWakeCallback pWakeCallback,
1667  void *pData) {
1668 
1669  ImplSVData * pSVData = ImplGetSVData();
1670  if (pSVData)
1671  {
1672  pSVData->mpPollCallback = pPollCallback;
1673  pSVData->mpWakeCallback = pWakeCallback;
1674  pSVData->mpPollClosure = pData;
1675  }
1676 }
1677 
1679 {
1680  ImplSVData * pSVData = ImplGetSVData();
1681  if (pSVData)
1682  {
1683  // Not hyper-elegant - but in the case of Android & unipoll we need to detach
1684  // this thread from the JVM's clutches to avoid a crash closing document
1685  if (pSVData->mpPollClosure && pSVData->mpDefInst)
1686  pSVData->mpDefInst->releaseMainThread();
1687 
1688  // Just set mpPollClosure to null as that is what calling this means, that the callback data
1689  // points to an object that no longer exists. In particular, don't set
1690  // pSVData->mpPollCallback to nullptr as that is used to detect whether Unipoll is in use in
1691  // isUnipoll().
1692  pSVData->mpPollClosure = nullptr;
1693  }
1694 }
1695 
1697 {
1698  ImplSVData * pSVData = ImplGetSVData();
1699  return pSVData && pSVData->mpPollCallback != nullptr;
1700 }
1701 
1702 } // namespace lok, namespace vcl
1703 
1704 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static OUString GetDisplayName()
Get the default name of the application for message dialogs and printing.
Definition: svapp.cxx:1200
do not automatically cancel dialogs
long getHeight() const
constexpr sal_uInt16 KEY_4
Definition: keycodes.hxx:49
const OUString & SalGetDesktopEnvironment()
Definition: salplug.cxx:308
virtual void Shutdown()
Definition: svapp.cxx:190
static bool bEventTestingMode
Definition: svapp.cxx:1555
static OUString GetAppName()
Get the application's name.
Definition: svapp.cxx:1127
vcl::Window * ImplGetWindow() const
if this is a proxy return the client, otherwise itself
Definition: window2.cxx:835
const int SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK
Definition: salsys.hxx:28
const LocaleDataWrapper & GetLocaleDataWrapper() const
constexpr sal_uInt16 KEY_7
Definition: keycodes.hxx:52
static void AcquireSolarMutex(sal_uInt32 nCount)
Acquire Solar Mutex(es) for this thread.
Definition: svapp.cxx:550
oslThreadIdentifier mnMainThreadId
Definition: svdata.hxx:404
VclPtr< vcl::Window > mpFocusWin
Definition: svdata.hxx:247
Application()
Default constructor for Application class.
Definition: svapp.cxx:158
constexpr sal_uInt16 KEY_MOD1
Definition: keycodes.hxx:31
static comphelper::SolarMutex & GetSolarMutex()
Get the Solar Mutex for this thread.
Definition: svapp.cxx:533
static bool IsUICaptured()
Definition: svapp.cxx:587
static bool IsMainThread()
Queries whether we are in main thread.
Definition: svapp.cxx:539
void SetFilterHdl(const Link< ConvertData &, bool > &rLink)
Definition: cvtgrf.hxx:45
static bool IsInExecute()
Queries whether the application is in the event loop.
Definition: svapp.cxx:562
static vcl::Window * GetTopWindow(long nIndex)
Get the nth top window.
Definition: svapp.cxx:1090
std::optional< OUString > mxToolkitName
Definition: svdata.hxx:142
Link< LinkParamNone *, void > maDeInitHook
Definition: svdata.hxx:418
static void NotifyAllWindows(DataChangedEvent &rDCEvt)
Notify all windows that the application has changed data.
Definition: svapp.cxx:742
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_Int32 mnX
Help * mpHelp
Definition: svdata.hxx:143
const LanguageTag & GetUILanguageTag() const
std::unique_ptr< ContentProperties > pData
VclPtr< VirtualDevice > mpNext
Definition: virdev.hxx:50
static bool IsBitmapRendering()
Determines if bitmap rendering is enabled.
Definition: svapp.cxx:1544
void NotifyAllChildren(DataChangedEvent &rDCEvt)
Definition: event.cxx:39
static sal_uInt16 GetDispatchLevel()
Return how many events are being dispatched.
Definition: svapp.cxx:572
virtual void InitFinished()
Finish initialization of the application.
Definition: svapp.cxx:198
constexpr sal_uInt16 KEY_2
Definition: keycodes.hxx:47
Definition: help.hxx:60
static Help * GetHelp()
Gets the application's help.
Definition: svapp.cxx:1353
ImplPostEventData(VclEventId nEvent, vcl::Window *pWin, const GestureEvent &rGestureEvent)
Definition: svapp.cxx:142
static SAL_DLLPRIVATE void ImplInitAppFontData(vcl::Window const *pWindow)
Definition: window.cxx:1168
LanguageType getLanguageType(bool bResolveSystem=true) const
static vcl::Window * GetDefDialogParent()
Get the default parent window for dialog boxes.
Definition: svapp.cxx:1367
ImplSVAppData maAppData
Definition: svdata.hxx:392
long GetOutOffXPixel() const
Definition: outdev.hxx:445
static void RemoveEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
Remove a VCL event listener from the application.
Definition: svapp.cxx:781
void SetMiscSettings(const MiscSettings &rSet)
MouseEventModifiers GetMode() const
Definition: event.hxx:121
static size_t GetReservedKeyCodeCount()
Get the number of reserved key codes used by the application.
Definition: svapp.cxx:284
KeyEvent maKeyEvent
Definition: svapp.cxx:126
bool ImplWindowFrameProc(vcl::Window *_pWindow, SalEvent nEvent, const void *pEvent)
Definition: winproc.cxx:2349
void * mpPollClosure
Definition: svdata.hxx:423
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:715
constexpr sal_uInt16 KEY_0
Definition: keycodes.hxx:45
virtual bool IsMainThread() const =0
static ImplSVEvent * PostGestureEvent(VclEventId nEvent, vcl::Window *pWin, GestureEvent const *pGestureEvent)
Definition: svapp.cxx:847
#define PRIO_COUNT
Definition: task.hxx:39
virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:190
SAL_DLLPRIVATE void SetDPIX(sal_Int32 nDPIX)
Definition: outdev.hxx:511
bool IsMapModeEnabled() const
Definition: outdev.hxx:1673
Important idle events to be run before processing drawing events.
sal_Int64 n
std::unique_ptr< AllSettings > mpSettings
Definition: svdata.hxx:132
ImplPostEventData(VclEventId nEvent, vcl::Window *pWin, const KeyEvent &rKeyEvent)
Definition: svapp.cxx:130
static void LockFontUpdates(bool bLock)
Lock font updates for all output devices.
Definition: svapp.cxx:1050
IMPL_STATIC_LINK_NOARG(ImplSVAppData, ImplEndAllPopupsMsg, void *, void)
Definition: svapp.cxx:297
constexpr sal_uInt16 KEY_F4
Definition: keycodes.hxx:86
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
Post a user event to the default window.
Definition: svapp.cxx:1007
const MapMode & GetMapMode() const
Definition: outdev.hxx:1679
static void EndAllPopups()
Cancel all open popups.
Definition: svapp.cxx:319
static bool IsUnifiedDisplay()
Determines if the screens that make up a display are separate or form one large display area...
Definition: svapp.cxx:1217
virtual int ShowNativeMessageBox(const OUString &rTitle, const OUString &rMessage)=0
Idle * mpEventTestingIdle
Definition: svdata.hxx:158
static void LockFontUpdates(bool bLock)
static void EnableSafeMode()
Set safe mode to enabled.
Definition: svapp.cxx:1574
constexpr sal_uInt16 KEY_F6
Definition: keycodes.hxx:88
static void EndAllDialogs()
Cancel all open dialogs.
Definition: svapp.cxx:314
bool InitAccessBridge()
Definition: svapp.cxx:1607
virtual unsigned int GetDisplayBuiltInScreen()
Definition: salsys.hxx:56
constexpr sal_uInt16 KEY_ADD
Definition: keycodes.hxx:127
std::vector< Link< VclWindowEvent &, bool > > maKeyListeners
Definition: svdata.hxx:136
virtual void Exception(ExceptionCategory nCategory)
Handles an error.
Definition: svapp.cxx:239
virtual bool AnyInput(VclInputFlags nType)=0
An application can be notified of a number of different events:
Definition: svapp.hxx:120
static void AddEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
Add a VCL event listener to the application.
Definition: svapp.cxx:775
ImplSchedulerData * mpFirstSchedulerData[PRIO_COUNT]
list of all active tasks per priority
Definition: svdata.hxx:365
virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:192
static bool ImplYield(bool i_bWait, bool i_bAllEvents)
Definition: svapp.cxx:441
void SetMapMode()
Definition: map.cxx:655
static void EnableConsoleOnly()
Enable Console Only mode.
Definition: svapp.cxx:1549
ImplSVGDIData maGDIData
Definition: svdata.hxx:393
std::optional< OUString > mxAppFileName
Definition: svdata.hxx:140
bool mbInAppExecute
Definition: svdata.hxx:151
virtual bool hasNativeFileSelection() const
Definition: salinst.hxx:188
static const OUString & GetDesktopEnvironment()
Get the desktop environment the process is currently running in.
Definition: svapp.cxx:1590
static OUString GetCommandLineParam(sal_uInt16 nParam)
Gets a particular command line parameter.
Definition: svapp.cxx:211
VclInputFlags
Definition: inputtypes.hxx:25
static css::uno::Reference< css::awt::XDisplayConnection > GetDisplayConnection()
Definition: svapp.cxx:1502
GestureEventType meEventType
static bool IsSafeModeEnabled()
Determines if safe mode is enabled.
Definition: svapp.cxx:1569
constexpr sal_uInt16 KEY_F1
Definition: keycodes.hxx:83
bool mbAppQuit
Definition: svdata.hxx:152
bool mbResLocaleSet
Definition: svdata.hxx:389
bool IsActive() const
Definition: task.hxx:90
AllSettingsFlags
Definition: settings.hxx:668
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Definition: svapp.cxx:1060
constexpr sal_uInt16 KEY_9
Definition: keycodes.hxx:54
virtual tools::Rectangle GetDisplayScreenPosSizePixel(unsigned int nScreen)=0
sal_uInt16 GetClicks() const
Definition: event.hxx:123
bool mbSettingsInit
Definition: svdata.hxx:153
long Right() const
static void ImplCallEventListenersApplicationDataChanged(void *pData)
Send event to all VCL application event listeners.
Definition: svapp.cxx:761
std::vector< ImplPostEventPair > maPostedEventList
Definition: svdata.hxx:137
virtual bool Close() override
Definition: wrkwin.cxx:249
void AcquireYieldMutex(sal_uInt32 nCount=1)
Definition: salvtables.cxx:115
LibreOfficeKitPollCallback mpPollCallback
Definition: svdata.hxx:421
static void SetFilterHdl(const Link< ConvertData &, bool > &rLink)
Setup a new graphics filter.
Definition: svapp.cxx:1515
virtual unsigned int GetDisplayScreenCount()=0
UnoWrapperBase *(* FN_TkCreateUnoWrapper)()
Definition: svapp.cxx:118
sal_uInt16 GetButtons() const
Definition: event.hxx:144
static unsigned int GetDisplayExternalScreen()
Get the display's external screen.
Definition: svapp.cxx:1229
static void Yield()
Process the next event.
Definition: svapp.cxx:517
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void removeListener(const Link< VclSimpleEvent &, void > &rListener)
Definition: vclevent.cxx:64
constexpr sal_uInt16 KEY_1
Definition: keycodes.hxx:46
static bool IsFuzzing()
void SalAbort(const OUString &rErrorText, bool bDumpCore)
Definition: salplug.cxx:293
constexpr sal_uInt16 KEY_F2
Definition: keycodes.hxx:84
virtual void Start() override
Activates the timer task.
Definition: idle.cxx:34
static void RemoveKeyListener(const Link< VclWindowEvent &, bool > &rKeyListener)
Remove a keypress listener from the application.
Definition: svapp.cxx:793
VclEventId
Definition: vclevent.hxx:39
bool IsTopWindow() const
Definition: stacking.cxx:612
bool mbScreenComp
Definition: virdev.hxx:52
#define SV_APP_VCLBACKEND
Definition: strings.hxx:13
static void SetAppName(const OUString &rUniqueName)
Set the application's name.
Definition: svapp.cxx:1121
static void Quit()
Quit the program.
Definition: svapp.cxx:527
VclPtr< VirtualDevice > mpFirstVirDev
Definition: svdata.hxx:217
long Top() const
ImplSchedulerData * mpNext
Pointer to the next element in list.
tools::Rectangle GetIntersection(const tools::Rectangle &rRect) const
static SystemWindowFlags GetSystemWindowMode()
Get the system window mode of dialogs.
Definition: svapp.cxx:1444
static bool isVCLOpenGLEnabled()
Returns true if VCL has OpenGL rendering enabled.
Application * GetpApp()
Definition: svapp.cxx:150
ExceptionCategory
virtual void updateMainThread()
Set the app's (somewhat) magic/main-thread to this one.
Definition: salinst.hxx:201
sal_uInt16 nCode
MouseEvent maMouseEvent
Definition: svapp.cxx:127
void Call(VclSimpleEvent &rEvent) const
Definition: vclevent.cxx:26
void registerPollCallbacks(LibreOfficeKitPollCallback pPollCallback, LibreOfficeKitWakeCallback pWakeCallback, void *pData)
Definition: svapp.cxx:1664
static void ImplCallEventListeners(VclSimpleEvent &rEvent)
Send event to all VCL application event listeners.
Definition: svapp.cxx:769
static bool IsDialogCancelEnabled()
Determines if dialog cancel mode is enabled.
Definition: svapp.cxx:1434
#define SAL_N_ELEMENTS(arr)
WinBits const WB_INTROWIN
LibreOfficeKitWakeCallback mpWakeCallback
Definition: svdata.hxx:422
static ImplSVEvent * PostMouseEvent(VclEventId nEvent, vcl::Window *pWin, MouseEvent const *pMouseEvent)
Send mouse event.
Definition: svapp.cxx:883
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
Remove user event based on event ID.
Definition: svapp.cxx:1035
GraphicConverter * mpGrfConverter
Definition: svdata.hxx:225
static vcl::Window * GetFirstTopLevelWindow()
Get the first top-level window of the application.
Definition: svapp.cxx:1065
static bool IsEventTestingModeEnabled()
Determines if event testing mode is enabled.
Definition: svapp.cxx:1557
constexpr sal_uInt16 KEY_5
Definition: keycodes.hxx:50
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:76
static bool bSafeMode
Definition: svapp.cxx:1567
void clear()
Definition: vclptr.hxx:190
void RemoveAccel(Accelerator const *pAccel)
Definition: accmgr.cxx:47
SalSystem * ImplGetSalSystem()
Definition: svdata.cxx:80
static tools::Rectangle GetScreenPosSizePixel(unsigned int nScreen)
Get a screen's rectangular area.
Definition: svapp.cxx:1252
VclPtr< vcl::Window > mpCaptureWin
Definition: svdata.hxx:248
bool mbCall
Definition: svdata.hxx:457
static bool Reschedule(bool bHandleAllCurrentEvents=false)
Attempt to process current pending event(s)
Definition: svapp.cxx:466
silently cancel any dialogs
static void ShowNativeErrorBox(const OUString &sTitle, const OUString &sMessage)
Definition: svapp.cxx:1579
SvFileStream * mpEventTestInput
Definition: svdata.hxx:157
comphelper::SolarMutex * GetYieldMutex()
Definition: salvtables.cxx:111
ImplPostEventData(VclEventId nEvent, vcl::Window *pWin, const MouseEvent &rMouseEvent)
Definition: svapp.cxx:136
int i
void unregisterPollCallbacks()
Definition: svapp.cxx:1678
virtual bool PostEvent(std::unique_ptr< ImplSVEvent > pData)=0
virtual void releaseMainThread()
Disconnect that - good for detaching from the JavaVM on Android.
Definition: salinst.hxx:203
VclPtr< vcl::Window > mpInstanceRef
Definition: svdata.hxx:455
static long GetTopWindowCount()
Return the number of top-level windows being used by the application.
Definition: svapp.cxx:1076
void EndAllDialogs(vcl::Window const *pParent)
Definition: dialog.cxx:1159
static bool AnyInput(VclInputFlags nType=VCL_INPUT_ANY)
Determine if there are any pending input events.
Definition: svapp.cxx:577
static const LocaleDataWrapper & GetAppLocaleDataWrapper()
Get the application's locale data wrapper.
Definition: svapp.cxx:1520
static void SetSystemWindowMode(SystemWindowFlags nMode)
Make a dialog box a system window or not.
Definition: svapp.cxx:1439
virtual OUString getOSVersion()
get information about underlying versions
Definition: salinst.hxx:206
static void SetSettings(const AllSettings &rSettings)
Sets the application's settings and notifies all windows of the change.
Definition: svapp.cxx:621
Definition: svapp.cxx:1136
static bool InsertAccel(Accelerator *pAccel)
Insert accelerator.
Definition: svapp.cxx:1324
Task * mpTask
Pointer to VCL Task instance.
static css::uno::Reference< css::ui::dialogs::XFilePicker2 > createFilePicker(const css::uno::Reference< css::uno::XComponentContext > &rServiceManager)
Create a platform specific file picker, if one is available, otherwise return an empty reference...
Definition: svapp.cxx:1640
SystemWindowFlags
Definition: svapp.hxx:92
static void EnableEventTestingMode()
Enables event testing mode.
Definition: svapp.cxx:1562
static void UpdateMainThread()
Update main thread identifier.
Definition: svapp.cxx:1346
VclPtr< WorkWindow > mpAppWin
Definition: svdata.hxx:239
sal_uInt16 & nParam
bool IsMenuFloatingWindow() const
Definition: window2.cxx:1007
SystemWindowFlags mnSysWinMode
Definition: svdata.hxx:149
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
static OUString GetToolkitName()
Get the toolkit's name.
Definition: svapp.cxx:1358
long Bottom() const
static ImplSVEvent * PostKeyEvent(VclEventId nEvent, vcl::Window *pWin, KeyEvent const *pKeyEvent)
Send keypress event.
Definition: svapp.cxx:824
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:510
constexpr sal_uInt16 KEY_3
Definition: keycodes.hxx:48
LocaleConfigurationListener * mpCfgListener
Definition: svdata.hxx:133
static sal_uInt64 GetLastInputInterval()
The interval from the last time that input was received.
Definition: svapp.cxx:582
VclPtr< vcl::Window > mpWin
Definition: svapp.cxx:124
bool IsInside(const Point &rPOINT) const
static bool HandleKey(VclEventId nEvent, vcl::Window *pWin, KeyEvent *pKeyEvent)
Handle keypress event.
Definition: svapp.cxx:800
IMPL_STATIC_LINK(Application, PostEventHandler, void *, pCallData, void)
Definition: svapp.cxx:919
sal_uInt32 ReleaseYieldMutexAll()
Definition: salvtables.cxx:113
GestureEvent maGestureEvent
Definition: svapp.cxx:128
static unsigned int GetScreenCount()
Get the number of screens available for the display.
Definition: svapp.cxx:1211
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:237
static SAL_DLLPRIVATE unsigned int GetBestScreen(const tools::Rectangle &)
Get the "best" screen.
Definition: svapp.cxx:1278
sal_uInt16 GetModifier() const
Definition: event.hxx:153
constexpr sal_uInt16 KEY_MOD2
Definition: keycodes.hxx:32
virtual void AppEvent(const ApplicationEvent &rAppEvent)
Definition: svapp.cxx:1629
constexpr sal_uInt16 KEY_F10
Definition: keycodes.hxx:92
VclPtr< vcl::Window > mpTrackWin
Definition: svdata.hxx:253
SAL_DLLPRIVATE vcl::Window * ImplGetClientWindow() const
Definition: window2.cxx:870
static DialogCancelMode GetDialogCancelMode()
Gets the dialog cancel mode for headless environments.
Definition: svapp.cxx:1424
static vcl::Window * GetActiveTopWindow()
Get the "active" top window.
Definition: svapp.cxx:1109
constexpr sal_uInt16 KEY_6
Definition: keycodes.hxx:51
static bool IsInMain()
Queries whether the application is in "main", i.e.
Definition: svapp.cxx:556
SalEvent
Definition: salwtype.hxx:40
ImplSchedulerContext maSchedCtx
Definition: svdata.hxx:391
sal_Int32 mnOffset
static void MergeSystemSettings(AllSettings &rSettings)
Set the settings object to the platform/desktop environment system settings.
Definition: svapp.cxx:602
static sal_uInt16 GetCommandLineParamCount()
Gets the number of command line parameters passed to the application.
Definition: svapp.cxx:206
SalFrame * ImplGetFrame() const
Definition: window2.cxx:848
virtual void Init()
Initialize the application itself.
Definition: svapp.cxx:194
virtual bool IsUnifiedDisplay()
Definition: salsys.hxx:49
static void SetDialogCancelMode(DialogCancelMode mode)
Sets the dialog cancel mode for headless environments.
Definition: svapp.cxx:1429
static vcl::Window * GetFocusWindow()
Get the currently focused window.
Definition: svapp.cxx:1055
static void AddToRecentDocumentList(const OUString &rFileUrl, const OUString &rMimeType, const OUString &rDocumentService)
Add a file to the system shells recent document list if there is any.
Definition: svapp.cxx:1601
static OUString GetHWOSConfInfo(const int bSelection=0)
Get useful OS, Hardware and configuration information, cf.
Definition: svapp.cxx:1138
static void setDeInitHook(Link< LinkParamNone *, void > const &hook)
Definition: svapp.cxx:1653
VCL_DLLPUBLIC bool isVCLSkiaEnabled()
static bool IsInModalMode()
Queries whether application has a modal dialog active.
Definition: svapp.cxx:567
constexpr sal_uInt16 KEY_8
Definition: keycodes.hxx:53
static sal_uInt32 ReleaseSolarMutex()
Release Solar Mutex(es) for this thread.
Definition: svapp.cxx:544
static void Abort(const OUString &rErrorText)
Ends the program prematurely with an error message.
Definition: svapp.cxx:263
ImplSVEvent * mnEventId
Definition: svapp.cxx:125
static vcl::Window * GetNextTopLevelWindow(vcl::Window const *pWindow)
Get the next top level window.
Definition: svapp.cxx:1071
static bool IsHeadlessModeEnabled()
Determines if headless mode is enabled.
Definition: svapp.cxx:1534
#define SAL_WARN_IF(condition, area, stream)
void ImplDeInitSVData()
Definition: svdata.cxx:88
bool isUnipoll()
Definition: svapp.cxx:1696
sal_Int32 mnY
ImplSVFrameData maFrameData
Definition: svdata.hxx:394
virtual OUString GetText() const override
Definition: syswin.cxx:1109
static void SetHelp(Help *pHelp=nullptr)
Sets up help.
Definition: svapp.cxx:1341
#define SAL_INFO(area, stream)
static css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rServiceManager)
Create a platform specific folder picker, if one is available, otherwise return an empty reference...
Definition: svapp.cxx:1647
VclPtr< vcl::Window > mpActiveApplicationFrame
Definition: svdata.hxx:238
TOOLKIT_DLLPUBLIC UnoWrapperBase * CreateUnoWrapper()
static void EnableBitmapRendering()
Enable software-only bitmap rendering.
Definition: svapp.cxx:1539
virtual void AddToRecentDocumentList(const OUString &rFileUrl, const OUString &rMimeType, const OUString &rDocumentService)=0
sal_uInt16 mnDispatchLevel
Definition: svdata.hxx:147
IMPL_LINK_NOARG(ImplSVAppData, VclEventTestingHdl, Timer *, void)
Definition: svapp.cxx:376
SAL_DLLPUBLIC_EXPORT void unit_lok_process_events_to_idle()
used by unit tests that test only via the LOK API
Definition: svapp.cxx:510
PanningOrientation meOrientation
VclEventId mnEvent
Definition: svapp.cxx:123
VclEventListeners maEventListeners
Definition: svdata.hxx:134
cancel any dialogs by std::abort
void release() const
static void ProcessEventsToIdle()
Process all events until none is pending.
Definition: svapp.cxx:471
static css::uno::Reference< css::awt::XToolkit > GetVCLToolkit()
Gets the VCL toolkit.
Definition: svapp.cxx:1449
void SetInvokeHandler(const Link< Timer *, void > &rLink)
Definition: timer.hxx:56
SAL_DLLPRIVATE void SetDPIY(sal_Int32 nDPIY)
Definition: outdev.hxx:512
virtual bool QueryExit()
Exit from the application.
Definition: svapp.cxx:179
long GetOutOffYPixel() const
Definition: outdev.hxx:446
const Point & GetPosPixel() const
Definition: event.hxx:120
virtual void OverrideSystemSettings(AllSettings &rSettings)
Sets user settings in settings object to override system settings.
Definition: svapp.cxx:598
static sal_uInt64 GetSystemTicks()
static void EnableHeadlessMode(bool dialogsAreFatal)
Enables headless mode.
Definition: svapp.cxx:1525
long Left() const
SAL_DLLPRIVATE void ImplUpdateGlobalSettings(AllSettings &rSettings, bool bCallHdl=true) const
VclPtr< FloatingWindow > mpFirstFloat
Definition: svdata.hxx:250
VclPtr< vcl::Window > mpWindow
Definition: svdata.hxx:456
bool good() const
virtual void DeInit()
Deinitialized the application itself.
Definition: svapp.cxx:202
DialogCancelMode meDialogCancel
Definition: svdata.hxx:154
static void RemoveMouseAndKeyEvents(vcl::Window *pWin)
Remove mouse and keypress events from a window...
Definition: svapp.cxx:984
bool mbRenderToBitmaps
Definition: svdata.hxx:155
const MiscSettings & GetMiscSettings() const
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
VclPtr< vcl::Window > mpFirstFrame
Definition: svdata.hxx:237
Application * mpApp
Definition: svdata.hxx:382
#define SAL_WARN(area, stream)
ImplAccelManager * mpAccelMgr
Definition: svdata.hxx:138
OUString VclResId(const char *pId)
Definition: svdata.cxx:267
Definition: timer.hxx:26
void SetPriority(TaskPriority ePriority)
Definition: scheduler.cxx:600
static unsigned int GetDisplayBuiltInScreen()
Get the built-in screen.
Definition: svapp.cxx:1223
virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents)=0
Wait for the next event (if bWait) and dispatch it, includes posted events, and timers.
#define DBG_TESTSOLARMUTEX()
std::optional< OUString > mxDisplayName
Definition: svdata.hxx:141
std::optional< OUString > mxAppName
Definition: svdata.hxx:139
DialogCancelMode
Definition: svapp.hxx:217
static const vcl::KeyCode * GetReservedKeyCode(size_t i)
Get the reserved key code.
Definition: svapp.cxx:289
rtl::Reference< vcl::DisplayConnectionDispatch > mxDisplayConnection
Definition: svdata.hxx:405
constexpr sal_uInt16 KEY_SHIFT
Definition: keycodes.hxx:30
bool InsertAccel(Accelerator *pAccel)
Definition: accmgr.cxx:31
virtual ~Application()
Virtual destructor for Application class.
Definition: svapp.cxx:167
UnoWrapperBase * mpUnoWrapper
Definition: svdata.hxx:399
vcl::Window * ImplGetDefaultWindow()
Returns either the application window, or the default GL context window.
Definition: svdata.cxx:211
static OUString GetAppFileName()
Get the name of the file used to start the application.
Definition: svapp.cxx:218
const char * GetDebugName() const
Definition: task.hxx:82
bool mbInAppMain
Definition: svdata.hxx:150
SAL_DLLPRIVATE sal_Int32 GetDPIY() const
Get the output device's DPI y-axis value.
Definition: outdev.hxx:509
AllSettingsFlags GetChangeFlags(const AllSettings &rSettings) const
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
Definition: floatwin.cxx:927
static void thisModule()
Definition: svapp.cxx:1464
int mnEventTestLimit
Definition: svdata.hxx:159
static void RemoveAccel(Accelerator const *pAccel)
Remove accelerator.
Definition: svapp.cxx:1333
AnyEventRef aEvent
SalInstance * mpDefInst
Definition: svdata.hxx:381
SAL_DLLPRIVATE sal_Int32 GetDPIX() const
Get the output device's DPI x-axis value.
Definition: outdev.hxx:503
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:30
bool mbInScheduler
Task currently processed?
ImplSVWinData * mpWinData
Definition: svdata.hxx:395
static void SetDisplayName(const OUString &rDisplayName)
Set the default name of the application for message dialogs and printing.
Definition: svapp.cxx:1194
void addListener(const Link< VclSimpleEvent &, void > &rListener)
Definition: vclevent.cxx:59
void UpdateSettings(const AllSettings &rSettings, bool bChild=false)
static void Execute()
Run the main event processing loop until it is quit by Quit().
Definition: svapp.cxx:417
static bool hasNativeFileSelection()
Do we have a native / system file selector available?
Definition: svapp.cxx:1633
static void AddKeyListener(const Link< VclWindowEvent &, bool > &rKeyListener)
Add a keypress listener to the application.
Definition: svapp.cxx:787
virtual int Main()
Pure virtual entrypoint to the application.
Definition: svapp.cxx:173
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo