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