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