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