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