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  : mnEvent(nEvent)
133  , mpWin(pWin)
134  , mnEventId(nullptr)
135  , maKeyEvent(rKeyEvent)
136  {}
137  ImplPostEventData(VclEventId nEvent, vcl::Window* pWin, const MouseEvent& rMouseEvent)
138  : mnEvent(nEvent)
139  , mpWin(pWin)
140  , mnEventId(nullptr)
141  , maMouseEvent(rMouseEvent)
142  {}
143  ImplPostEventData(VclEventId nEvent, vcl::Window* pWin, const GestureEvent& rGestureEvent)
144  : mnEvent(nEvent)
145  , mpWin(pWin)
146  , mnEventId(nullptr)
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.mpSettings );
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.mpSettings )
645  {
646  InitSettings(pSVData);
647  *pSVData->maAppData.mpSettings = rSettings;
648  }
649  else
650  {
651  AllSettings aOldSettings = *pSVData->maAppData.mpSettings;
652  if (aOldSettings.GetUILanguageTag().getLanguageType() != rSettings.GetUILanguageTag().getLanguageType() &&
653  pSVData->mbResLocaleSet)
654  {
655  pSVData->mbResLocaleSet = false;
656  }
657  *pSVData->maAppData.mpSettings = rSettings;
658  AllSettingsFlags nChangeFlags = aOldSettings.GetChangeFlags( *pSVData->maAppData.mpSettings );
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.mpSettings )
737  {
738  InitSettings(pSVData);
739  }
740 
741  return *(pSVData->maAppData.mpSettings);
742 }
743 
744 namespace {
745 
746 void InitSettings(ImplSVData* pSVData)
747 {
748  assert(!pSVData->maAppData.mpSettings && "initialization should not happen twice!");
749 
750  pSVData->maAppData.mpSettings.reset(new AllSettings());
752  {
754  pSVData->maAppData.mpSettings->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(std::string_view 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::RenderRaster:
1190  appendDetails(u"", Localize(SV_APP_SKIA_RASTER, bLocalize));
1191  break;
1192  }
1193  }
1194  else
1195 #endif
1196  appendDetails(u"", Localize(SV_APP_DEFAULT, bLocalize));
1197 
1198 #if (defined LINUX || defined _WIN32 || defined MACOSX || defined __FreeBSD__)
1199  appendDetails(u"; ", SV_APP_VCLBACKEND + GetToolkitName());
1200 #endif
1201  }
1202 
1203  return aDetails.makeStringAndClear();
1204 }
1205 
1206 void Application::SetDisplayName( const OUString& rName )
1207 {
1208  ImplSVData* pSVData = ImplGetSVData();
1209  pSVData->maAppData.mxDisplayName = rName;
1210 }
1211 
1213 {
1214  ImplSVData* pSVData = ImplGetSVData();
1215  if ( pSVData->maAppData.mxDisplayName )
1216  return *(pSVData->maAppData.mxDisplayName);
1217  else if (pSVData->maFrameData.mpAppWin)
1218  return pSVData->maFrameData.mpAppWin->GetText();
1219  else
1220  return OUString();
1221 }
1222 
1224 {
1225  SalSystem* pSys = ImplGetSalSystem();
1226  return pSys ? pSys->GetDisplayScreenCount() : 0;
1227 }
1228 
1230 {
1231  SalSystem* pSys = ImplGetSalSystem();
1232  return pSys == nullptr || pSys->IsUnifiedDisplay();
1233 }
1234 
1236 {
1237  SalSystem* pSys = ImplGetSalSystem();
1238  return pSys ? pSys->GetDisplayBuiltInScreen() : 0;
1239 }
1240 
1242 {
1243  // This is really unpleasant, in theory we could have multiple
1244  // external displays etc.
1245  int nExternal(0);
1246  switch (GetDisplayBuiltInScreen())
1247  {
1248  case 0:
1249  nExternal = 1;
1250  break;
1251  case 1:
1252  nExternal = 0;
1253  break;
1254  default:
1255  // When the built-in display is neither 0 nor 1
1256  // then place the full-screen presentation on the
1257  // first available screen.
1258  nExternal = 0;
1259  break;
1260  }
1261  return nExternal;
1262 }
1263 
1265 {
1266  SalSystem* pSys = ImplGetSalSystem();
1267  if (!pSys)
1268  {
1269  SAL_WARN("vcl", "Requesting screen size/pos for screen #" << nScreen << " failed");
1270  assert(false);
1271  return tools::Rectangle();
1272  }
1273  tools::Rectangle aRect = pSys->GetDisplayScreenPosSizePixel(nScreen);
1274  if (aRect.getHeight() == 0)
1275  SAL_WARN("vcl", "Requesting screen size/pos for screen #" << nScreen << " returned 0 height.");
1276  return aRect;
1277 }
1278 
1279 namespace {
1280 tools::Long calcDistSquare( const Point& i_rPoint, const tools::Rectangle& i_rRect )
1281 {
1282  const Point aRectCenter( (i_rRect.Left() + i_rRect.Right())/2,
1283  (i_rRect.Top() + i_rRect.Bottom())/ 2 );
1284  const tools::Long nDX = aRectCenter.X() - i_rPoint.X();
1285  const tools::Long nDY = aRectCenter.Y() - i_rPoint.Y();
1286  return nDX*nDX + nDY*nDY;
1287 }
1288 }
1289 
1290 unsigned int Application::GetBestScreen( const tools::Rectangle& i_rRect )
1291 {
1292  if( !IsUnifiedDisplay() )
1293  return GetDisplayBuiltInScreen();
1294 
1295  const unsigned int nScreens = GetScreenCount();
1296  unsigned int nBestMatchScreen = 0;
1297  unsigned long nOverlap = 0;
1298  for( unsigned int i = 0; i < nScreens; i++ )
1299  {
1300  const tools::Rectangle aCurScreenRect( GetScreenPosSizePixel( i ) );
1301  // if a screen contains the rectangle completely it is obviously the best screen
1302  if( aCurScreenRect.IsInside( i_rRect ) )
1303  return i;
1304  // next the screen which contains most of the area of the rect is the best
1305  tools::Rectangle aIntersection( aCurScreenRect.GetIntersection( i_rRect ) );
1306  if( ! aIntersection.IsEmpty() )
1307  {
1308  const unsigned long nCurOverlap( aIntersection.GetWidth() * aIntersection.GetHeight() );
1309  if( nCurOverlap > nOverlap )
1310  {
1311  nOverlap = nCurOverlap;
1312  nBestMatchScreen = i;
1313  }
1314  }
1315  }
1316  if( nOverlap > 0 )
1317  return nBestMatchScreen;
1318 
1319  // finally the screen which center is nearest to the rect is the best
1320  const Point aCenter( (i_rRect.Left() + i_rRect.Right())/2,
1321  (i_rRect.Top() + i_rRect.Bottom())/2 );
1322  tools::Long nDist = std::numeric_limits<tools::Long>::max();
1323  for( unsigned int i = 0; i < nScreens; i++ )
1324  {
1325  const tools::Rectangle aCurScreenRect( GetScreenPosSizePixel( i ) );
1326  const tools::Long nCurDist( calcDistSquare( aCenter, aCurScreenRect ) );
1327  if( nCurDist < nDist )
1328  {
1329  nBestMatchScreen = i;
1330  nDist = nCurDist;
1331  }
1332  }
1333  return nBestMatchScreen;
1334 }
1335 
1336 bool Application::InsertAccel( Accelerator* pAccel )
1337 {
1338  ImplSVData* pSVData = ImplGetSVData();
1339 
1340  if ( !pSVData->maAppData.mpAccelMgr )
1341  pSVData->maAppData.mpAccelMgr = new ImplAccelManager();
1342  return pSVData->maAppData.mpAccelMgr->InsertAccel( pAccel );
1343 }
1344 
1345 void Application::RemoveAccel( Accelerator const * pAccel )
1346 {
1347  ImplSVData* pSVData = ImplGetSVData();
1348 
1349  if ( pSVData->maAppData.mpAccelMgr )
1350  pSVData->maAppData.mpAccelMgr->RemoveAccel( pAccel );
1351 }
1352 
1354 {
1355  ImplGetSVData()->maAppData.mpHelp = pHelp;
1356 }
1357 
1359 {
1360  ImplSVData* pSVData = ImplGetSVData();
1361  if (pSVData && pSVData->mpDefInst)
1362  pSVData->mpDefInst->updateMainThread();
1363 }
1364 
1366 {
1367  return ImplGetSVData()->maAppData.mpHelp;
1368 }
1369 
1371 {
1372  ImplSVData* pSVData = ImplGetSVData();
1373  if ( pSVData->maAppData.mxToolkitName )
1374  return *(pSVData->maAppData.mxToolkitName);
1375  else
1376  return OUString();
1377 }
1378 
1380 {
1381  ImplSVData* pSVData = ImplGetSVData();
1382  // find some useful dialog parent
1383 
1384  // always use the topmost parent of the candidate
1385  // window to avoid using dialogs or floaters
1386  // as DefDialogParent
1387 
1388  // current focus frame
1389  vcl::Window *pWin = pSVData->mpWinData->mpFocusWin;
1390  if (pWin && !pWin->IsMenuFloatingWindow())
1391  {
1392  while (pWin->mpWindowImpl && pWin->mpWindowImpl->mpParent)
1393  pWin = pWin->mpWindowImpl->mpParent;
1394 
1395  // check for corrupted window hierarchy, #122232#, may be we now crash somewhere else
1396  if (!pWin->mpWindowImpl)
1397  {
1398  OSL_FAIL( "Window hierarchy corrupted!" );
1399  pSVData->mpWinData->mpFocusWin = nullptr; // avoid further access
1400  return nullptr;
1401  }
1402 
1403  if ((pWin->mpWindowImpl->mnStyle & WB_INTROWIN) == 0)
1404  {
1405  return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1406  }
1407  }
1408 
1409  // last active application frame
1410  pWin = pSVData->maFrameData.mpActiveApplicationFrame;
1411  if (pWin)
1412  {
1413  return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1414  }
1415 
1416  // first visible top window (may be totally wrong...)
1417  pWin = pSVData->maFrameData.mpFirstFrame;
1418  while (pWin)
1419  {
1420  if( pWin->ImplGetWindow()->IsTopWindow() &&
1421  pWin->mpWindowImpl->mbReallyVisible &&
1422  (pWin->mpWindowImpl->mnStyle & WB_INTROWIN) == 0
1423  )
1424  {
1425  while( pWin->mpWindowImpl->mpParent )
1426  pWin = pWin->mpWindowImpl->mpParent;
1427  return pWin->mpWindowImpl->mpFrameWindow->ImplGetWindow();
1428  }
1429  pWin = pWin->mpWindowImpl->mpFrameData->mpNextFrame;
1430  }
1431 
1432  // use the desktop
1433  return nullptr;
1434 }
1435 
1437 {
1439 }
1440 
1442 {
1444 }
1445 
1447 {
1449 }
1450 
1452 {
1454 }
1455 
1457 {
1459 }
1460 
1461 css::uno::Reference< css::awt::XToolkit > Application::GetVCLToolkit()
1462 {
1463  css::uno::Reference< css::awt::XToolkit > xT;
1465  if ( pWrapper )
1466  xT = pWrapper->GetVCLToolkit();
1467  return xT;
1468 }
1469 
1470 #ifdef DISABLE_DYNLOADING
1471 
1472 extern "C" { UnoWrapperBase* CreateUnoWrapper(); }
1473 
1474 #else
1475 
1476 extern "C" { static void thisModule() {} }
1477 
1478 #endif
1479 
1481 {
1482  ImplSVData* pSVData = ImplGetSVData();
1483  static bool bAlreadyTriedToCreate = false;
1484  if ( !pSVData->mpUnoWrapper && bCreateIfNotExist && !bAlreadyTriedToCreate )
1485  {
1486 #ifndef DISABLE_DYNLOADING
1487  osl::Module aTkLib;
1488  aTkLib.loadRelative(&thisModule, TK_DLL_NAME);
1489  if (aTkLib.is())
1490  {
1491  FN_TkCreateUnoWrapper fnCreateWrapper = reinterpret_cast<FN_TkCreateUnoWrapper>(aTkLib.getFunctionSymbol("CreateUnoWrapper"));
1492  if ( fnCreateWrapper )
1493  {
1494  pSVData->mpUnoWrapper = fnCreateWrapper();
1495  }
1496  aTkLib.release();
1497  }
1498  SAL_WARN_IF( !pSVData->mpUnoWrapper, "vcl", "UnoWrapper could not be created!" );
1499 #else
1500  pSVData->mpUnoWrapper = CreateUnoWrapper();
1501 #endif
1502  bAlreadyTriedToCreate = true;
1503  }
1504  return pSVData->mpUnoWrapper;
1505 }
1506 
1508 {
1509  ImplSVData* pSVData = ImplGetSVData();
1510  SAL_WARN_IF( pSVData->mpUnoWrapper, "vcl", "SetUnoWrapper: Wrapper already exists" );
1511  pSVData->mpUnoWrapper = pWrapper;
1512 }
1513 
1514 css::uno::Reference< css::awt::XDisplayConnection > Application::GetDisplayConnection()
1515 {
1516  ImplSVData* pSVData = ImplGetSVData();
1517 
1518  if( !pSVData->mxDisplayConnection.is() )
1519  {
1521  pSVData->mxDisplayConnection->start();
1522  }
1523 
1524  return pSVData->mxDisplayConnection;
1525 }
1526 
1528 {
1529  ImplGetSVData()->maGDIData.mxGrfConverter->SetFilterHdl( rLink );
1530 }
1531 
1533 {
1534  return GetSettings().GetLocaleDataWrapper();
1535 }
1536 
1537 void Application::EnableHeadlessMode( bool dialogsAreFatal )
1538 {
1539  DialogCancelMode eNewMode = dialogsAreFatal ? DialogCancelMode::Fatal : DialogCancelMode::Silent;
1541  assert(eOldMode == DialogCancelMode::Off || GetDialogCancelMode() == eNewMode);
1542  if (eOldMode != eNewMode)
1543  SetDialogCancelMode( eNewMode );
1544 }
1545 
1547 {
1549 }
1550 
1552 {
1554 }
1555 
1557 {
1559 }
1560 
1562 {
1563  EnableHeadlessMode(true);
1565 }
1566 
1567 static bool bEventTestingMode = false;
1568 
1570 {
1571  return bEventTestingMode;
1572 }
1573 
1575 {
1576  bEventTestingMode = true;
1577 }
1578 
1579 static bool bSafeMode = false;
1580 
1582 {
1583  return bSafeMode;
1584 }
1585 
1587 {
1588  bSafeMode = true;
1589 }
1590 
1591 void Application::ShowNativeErrorBox(const OUString& sTitle ,
1592  const OUString& sMessage)
1593 {
1595  sTitle,
1596  sMessage);
1597  if (btn != SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK) {
1598  SAL_WARN( "vcl", "ShowNativeMessageBox returned " << btn);
1599  }
1600 }
1601 
1603 {
1604  if (IsHeadlessModeEnabled())
1605  {
1606  static const OUString aNone("none");
1607  return aNone;
1608  }
1609  else
1610  return SalGetDesktopEnvironment();
1611 }
1612 
1613 void Application::AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService)
1614 {
1615  ImplSVData* pSVData = ImplGetSVData();
1616  pSVData->mpDefInst->AddToRecentDocumentList(rFileUrl, rMimeType, rDocumentService);
1617 }
1618 
1620 {
1621 // Disable MSAA bridge on UNIX
1622 #if defined UNX
1623  return true;
1624 #else
1625  bool bRet = ImplInitAccessBridge();
1626 
1627  if( !bRet )
1628  {
1629  // disable accessibility if the user chooses to continue
1630  AllSettings aSettings = Application::GetSettings();
1631  MiscSettings aMisc = aSettings.GetMiscSettings();
1632  aMisc.SetEnableATToolSupport( false );
1633  aSettings.SetMiscSettings( aMisc );
1634  Application::SetSettings( aSettings );
1635  }
1636  return bRet;
1637 #endif // !UNX
1638 }
1639 
1640 // MT: AppEvent was in oldsv.cxx, but is still needed...
1641 void Application::AppEvent( const ApplicationEvent& /*rAppEvent*/ )
1642 {
1643 }
1644 
1646 {
1647  ImplSVData* pSVData = ImplGetSVData();
1648  return pSVData->mpDefInst->hasNativeFileSelection();
1649 }
1650 
1651 Reference< ui::dialogs::XFilePicker2 >
1653 {
1654  ImplSVData* pSVData = ImplGetSVData();
1655  return pSVData->mpDefInst->createFilePicker( xSM );
1656 }
1657 
1658 Reference< ui::dialogs::XFolderPicker2 >
1660 {
1661  ImplSVData* pSVData = ImplGetSVData();
1662  return pSVData->mpDefInst->createFolderPicker( xSM );
1663 }
1664 
1666  ImplSVData * pSVData = ImplGetSVData();
1667  assert(!pSVData->maDeInitHook.IsSet());
1668  pSVData->maDeInitHook = hook;
1669  // Fake this for VCLXToolkit ctor instantiated from
1670  // postprocess/CppunitTest_services.mk:
1671  pSVData->maAppData.mbInAppMain = true;
1672 }
1673 
1674 namespace vcl::lok {
1675 
1677  LibreOfficeKitPollCallback pPollCallback,
1678  LibreOfficeKitWakeCallback pWakeCallback,
1679  void *pData) {
1680 
1681  ImplSVData * pSVData = ImplGetSVData();
1682  if (pSVData)
1683  {
1684  pSVData->mpPollCallback = pPollCallback;
1685  pSVData->mpWakeCallback = pWakeCallback;
1686  pSVData->mpPollClosure = pData;
1687  }
1688 }
1689 
1691 {
1692  ImplSVData * pSVData = ImplGetSVData();
1693  if (!pSVData)
1694  return;
1695 
1696  // Not hyper-elegant - but in the case of Android & unipoll we need to detach
1697  // this thread from the JVM's clutches to avoid a crash closing document
1698  if (pSVData->mpPollClosure && pSVData->mpDefInst)
1699  pSVData->mpDefInst->releaseMainThread();
1700 
1701  // Just set mpPollClosure to null as that is what calling this means, that the callback data
1702  // points to an object that no longer exists. In particular, don't set
1703  // pSVData->mpPollCallback to nullptr as that is used to detect whether Unipoll is in use in
1704  // isUnipoll().
1705  pSVData->mpPollClosure = nullptr;
1706 }
1707 
1709 {
1710  ImplSVData * pSVData = ImplGetSVData();
1711  return pSVData && pSVData->mpPollCallback != nullptr;
1712 }
1713 
1714 void numberOfViewsChanged(int count)
1715 {
1716  ImplSVData * pSVData = ImplGetSVData();
1717  auto& rCache = pSVData->maGDIData.maScaleCache;
1718  // Normally the cache size is set to 10, scale according to the number of users.
1719  rCache.setMaxSize(count * 10);
1720 }
1721 
1722 } // namespace lok, namespace vcl
1723 
1724 /* 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:1212
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:1567
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:829
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:403
VclPtr< vcl::Window > mpFocusWin
Definition: svdata.hxx:248
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:143
Link< LinkParamNone *, void > maDeInitHook
Definition: svdata.hxx:417
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: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:1556
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 sal_uInt16 KEY_2
Definition: keycodes.hxx:47
Definition: help.hxx:60
static Help * GetHelp()
Gets the application's help.
Definition: svapp.cxx:1365
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:1171
LanguageType getLanguageType(bool bResolveSystem=true) const
static vcl::Window * GetDefDialogParent()
Get the default parent window for dialog boxes.
Definition: svapp.cxx:1379
ImplSVAppData maAppData
Definition: svdata.hxx:391
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:226
KeyEvent maKeyEvent
Definition: svapp.cxx:127
bool ImplWindowFrameProc(vcl::Window *_pWindow, SalEvent nEvent, const void *pEvent)
Definition: winproc.cxx:2380
void * mpPollClosure
Definition: svdata.hxx:422
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:187
SAL_DLLPRIVATE void SetDPIX(sal_Int32 nDPIX)
Definition: outdev.hxx:382
bool IsMapModeEnabled() const
Definition: outdev.hxx:1556
Important idle events to be run before processing drawing events.
sal_Int64 n
std::unique_ptr< AllSettings > mpSettings
Definition: svdata.hxx:133
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:1562
static void EndAllPopups()
Cancel all open popups.
Definition: svapp.cxx:312
static bool IsUnifiedDisplay()
Determines if the screens that make up a display are separate or form one large display area...
Definition: svapp.cxx:1229
virtual int ShowNativeMessageBox(const OUString &rTitle, const OUString &rMessage)=0
Idle * mpEventTestingIdle
Definition: svdata.hxx:159
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:1586
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:1619
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:137
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:366
virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: salinst.hxx:189
static bool ImplYield(bool i_bWait, bool i_bAllEvents)
Definition: svapp.cxx:451
void SetMapMode()
Definition: map.cxx:551
static void EnableConsoleOnly()
Enable Console Only mode.
Definition: svapp.cxx:1561
ImplSVGDIData maGDIData
Definition: svdata.hxx:392
std::optional< OUString > mxAppFileName
Definition: svdata.hxx:141
bool mbInAppExecute
Definition: svdata.hxx:152
virtual bool hasNativeFileSelection() const
Definition: salinst.hxx:185
static const OUString & GetDesktopEnvironment()
Get the desktop environment the process is currently running in.
Definition: svapp.cxx:1602
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:1514
GestureEventType meEventType
static bool IsSafeModeEnabled()
Determines if safe mode is enabled.
Definition: svapp.cxx:1581
constexpr sal_uInt16 KEY_F1
Definition: keycodes.hxx:83
bool mbAppQuit
Definition: svdata.hxx:153
void setMaxSize(size_t nMaxSize)
bool mbResLocaleSet
Definition: svdata.hxx:388
bool IsActive() const
Definition: task.hxx:102
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
virtual tools::Rectangle GetDisplayScreenPosSizePixel(unsigned int nScreen)=0
sal_uInt16 GetClicks() const
Definition: event.hxx:126
void * m_pCallbackData
Definition: svapp.hxx:1331
bool mbSettingsInit
Definition: svdata.hxx:154
static void ImplCallEventListenersApplicationDataChanged(void *pData)
Send event to all VCL application event listeners.
Definition: svapp.cxx:779
std::vector< ImplPostEventPair > maPostedEventList
Definition: svdata.hxx:138
virtual bool Close() override
Definition: wrkwin.cxx:243
void AcquireYieldMutex(sal_uInt32 nCount=1)
Definition: salvtables.cxx:122
LibreOfficeKitPollCallback mpPollCallback
Definition: svdata.hxx:420
static void SetFilterHdl(const Link< ConvertData &, bool > &rLink)
Setup a new graphics filter.
Definition: svapp.cxx:1527
virtual unsigned int GetDisplayScreenCount()=0
UnoWrapperBase *(* FN_TkCreateUnoWrapper)()
Definition: svapp.cxx:119
sal_uInt16 GetButtons() const
Definition: event.hxx:147
tools::Long Left() const
static unsigned int GetDisplayExternalScreen()
Get the display's external screen.
Definition: svapp.cxx:1241
static void Yield()
Process the next event.
Definition: svapp.cxx:530
void removeListener(const Link< VclSimpleEvent &, void > &rListener)
Definition: vclevent.cxx:65
constexpr sal_uInt16 KEY_1
Definition: keycodes.hxx:46
static bool IsFuzzing()
void SalAbort(const OUString &rErrorText, bool bDumpCore)
Definition: salplug.cxx:317
tools::Long Bottom() const
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:1714
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:218
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:1456
Application * GetpApp()
Definition: svapp.cxx:151
ExceptionCategory
virtual void updateMainThread()
Set the app's (somewhat) magic/main-thread to this one.
Definition: salinst.hxx:198
sal_uInt16 nCode
MouseEvent maMouseEvent
Definition: svapp.cxx:128
void Call(VclSimpleEvent &rEvent) const
Definition: vclevent.cxx:26
void registerPollCallbacks(LibreOfficeKitPollCallback pPollCallback, LibreOfficeKitWakeCallback pWakeCallback, void *pData)
Definition: svapp.cxx:1676
static void ImplCallEventListeners(VclSimpleEvent &rEvent)
Send event to all VCL application event listeners.
Definition: svapp.cxx:787
static bool IsDialogCancelEnabled()
Determines if dialog cancel mode is enabled.
Definition: svapp.cxx:1446
#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:421
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:1569
constexpr sal_uInt16 KEY_5
Definition: keycodes.hxx:50
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
static bool bSafeMode
Definition: svapp.cxx:1579
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:1264
VclPtr< vcl::Window > mpCaptureWin
Definition: svdata.hxx:249
bool mbCall
Definition: svdata.hxx:456
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:1591
SvFileStream * mpEventTestInput
Definition: svdata.hxx:158
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:1690
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:200
VclPtr< vcl::Window > mpInstanceRef
Definition: svdata.hxx:454
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:1532
static void SetSystemWindowMode(SystemWindowFlags nMode)
Make a dialog box a system window or not.
Definition: svapp.cxx:1451
virtual OUString getOSVersion()
get information about underlying versions
Definition: salinst.hxx:203
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:1336
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:1652
SystemWindowFlags
Definition: svapp.hxx:87
static void EnableEventTestingMode()
Enables event testing mode.
Definition: svapp.cxx:1574
static void UpdateMainThread()
Update main thread identifier.
Definition: svapp.cxx:1358
VclPtr< WorkWindow > mpAppWin
Definition: svdata.hxx:240
sal_uInt16 & nParam
bool IsMenuFloatingWindow() const
Definition: window2.cxx:1006
SystemWindowFlags mnSysWinMode
Definition: svdata.hxx:150
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:162
static OUString GetToolkitName()
Get the toolkit's name.
Definition: svapp.cxx:1370
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:496
constexpr sal_uInt16 KEY_3
Definition: keycodes.hxx:48
LocaleConfigurationListener * mpCfgListener
Definition: svdata.hxx:134
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:125
bool IsInside(const Point &rPOINT) const
static bool HandleKey(VclEventId nEvent, vcl::Window *pWin, KeyEvent *pKeyEvent)
Handle keypress event.
Definition: svapp.cxx:818
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:1223
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:1290
sal_uInt16 GetModifier() const
Definition: event.hxx:156
virtual void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
Definition: svapp.cxx:323
tools::Long Top() const
constexpr sal_uInt16 KEY_MOD2
Definition: keycodes.hxx:32
virtual void AppEvent(const ApplicationEvent &rAppEvent)
Definition: svapp.cxx:1641
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:864
static DialogCancelMode GetDialogCancelMode()
Gets the dialog cancel mode for headless environments.
Definition: svapp.cxx:1436
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
OUString get(std::string_view sContextAndId, const std::locale &loc)
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:390
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
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:842
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:1441
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:1613
static void setDeInitHook(Link< LinkParamNone *, void > const &hook)
Definition: svapp.cxx:1665
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:1332
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:126
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:1546
#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:1507
bool isUnipoll()
Definition: svapp.cxx:1708
sal_Int32 mnY
ImplSVFrameData maFrameData
Definition: svdata.hxx:393
virtual OUString GetText() const override
Definition: syswin.cxx:1063
static void SetHelp(Help *pHelp=nullptr)
Sets up help.
Definition: svapp.cxx:1353
#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:1659
VclPtr< vcl::Window > mpActiveApplicationFrame
Definition: svdata.hxx:239
TOOLKIT_DLLPUBLIC UnoWrapperBase * CreateUnoWrapper()
OUString VclResId(std::string_view aId)
Definition: svdata.cxx:259
::OutputDevice const * GetOutDev() const
Definition: window.cxx:565
static void EnableBitmapRendering()
Enable software-only bitmap rendering.
Definition: svapp.cxx:1551
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: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:124
VclEventListeners maEventListeners
Definition: svdata.hxx:135
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:1461
void SetInvokeHandler(const Link< Timer *, void > &rLink)
Definition: timer.hxx:56
SAL_DLLPRIVATE void SetDPIY(sal_Int32 nDPIY)
Definition: outdev.hxx:383
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:1537
SAL_DLLPRIVATE void ImplUpdateGlobalSettings(AllSettings &rSettings, bool bCallHdl=true) const
VclPtr< FloatingWindow > mpFirstFloat
Definition: svdata.hxx:251
VclPtr< vcl::Window > mpWindow
Definition: svdata.hxx:455
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:155
static void RemoveMouseAndKeyEvents(vcl::Window *pWin)
Remove mouse and keypress events from a window...
Definition: svapp.cxx:1002
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:384
#define SAL_WARN(area, stream)
ImplAccelManager * mpAccelMgr
Definition: svdata.hxx:139
Definition: timer.hxx:26
void SetPriority(TaskPriority ePriority)
Definition: scheduler.cxx:597
static unsigned int GetDisplayBuiltInScreen()
Get the built-in screen.
Definition: svapp.cxx:1235
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
static UnoWrapperBase * GetUnoWrapper(bool bCreateIfNotExists=true)
Get the application's UNO wrapper object.
Definition: svapp.cxx:1480
std::optional< OUString > mxAppName
Definition: svdata.hxx:140
DialogCancelMode
Definition: svapp.hxx:212
lru_scale_cache maScaleCache
Definition: svdata.hxx:224
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:404
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:170
tools::Long GetOutOffXPixel() const
Definition: window3.cxx:123
UnoWrapperBase * mpUnoWrapper
Definition: svdata.hxx:398
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:221
const char * GetDebugName() const
Definition: task.hxx:83
bool mbInAppMain
Definition: svdata.hxx:151
SAL_DLLPRIVATE sal_Int32 GetDPIY() const
Get the output device's DPI y-axis value.
Definition: outdev.hxx:380
AllSettingsFlags GetChangeFlags(const AllSettings &rSettings) const
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
Definition: floatwin.cxx:944
static void thisModule()
Definition: svapp.cxx:1476
int mnEventTestLimit
Definition: svdata.hxx:160
static void RemoveAccel(Accelerator const *pAccel)
Remove accelerator.
Definition: svapp.cxx:1345
tools::Long Right() const
AnyEventRef aEvent
SalInstance * mpDefInst
Definition: svdata.hxx:383
SAL_DLLPRIVATE sal_Int32 GetDPIX() const
Get the output device's DPI x-axis value.
Definition: outdev.hxx:374
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:394
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:1206
void addListener(const Link< VclSimpleEvent &, void > &rListener)
Definition: vclevent.cxx:60
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:1645
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
static OUString Localize(std::string_view aId, const bool bLocalize)
Definition: svapp.cxx:1147
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo