LCOV - code coverage report
Current view: top level - include/vcl - svapp.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 55 67 82.1 %
Date: 2015-06-13 12:38:46 Functions: 15 21 71.4 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef INCLUDED_VCL_SVAPP_HXX
      21             : #define INCLUDED_VCL_SVAPP_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : #include <sal/types.h>
      25             : 
      26             : #include <cassert>
      27             : #include <stdexcept>
      28             : #include <vector>
      29             : 
      30             : #include <comphelper/solarmutex.hxx>
      31             : #include <rtl/ustring.hxx>
      32             : #include <osl/thread.hxx>
      33             : #include <tools/gen.hxx>
      34             : #include <tools/link.hxx>
      35             : #include <tools/solar.h>
      36             : #include <vcl/dllapi.h>
      37             : #include <vcl/apptypes.hxx>
      38             : #include <vcl/keycod.hxx>
      39             : #include <vcl/vclevent.hxx>
      40             : #include <vcl/metric.hxx>
      41             : #include <unotools/localedatawrapper.hxx>
      42             : #include <o3tl/typed_flags_set.hxx>
      43             : 
      44             : class BitmapEx;
      45             : class AllSettings;
      46             : class DataChangedEvent;
      47             : class Accelerator;
      48             : class Help;
      49             : class OutputDevice;
      50             : namespace vcl { class Window; }
      51             : class WorkWindow;
      52             : class MenuBar;
      53             : class UnoWrapperBase;
      54             : class Reflection;
      55             : class NotifyEvent;
      56             : class KeyEvent;
      57             : class MouseEvent;
      58             : class ZoomEvent;
      59             : class ScrollEvent;
      60             : struct ImplSVEvent;
      61             : 
      62             : #include <com/sun/star/uno/Reference.h>
      63             : #include <com/sun/star/connection/XConnection.hpp>
      64             : 
      65             : namespace com {
      66             : namespace sun {
      67             : namespace star {
      68             : namespace uno {
      69             :     class XComponentContext;
      70             : }
      71             : namespace ui {
      72             :     namespace dialogs {
      73             :         class XFilePicker2;
      74             :         class XFolderPicker2;
      75             :     }
      76             : }
      77             : namespace awt {
      78             :     class XToolkit;
      79             :     class XDisplayConnection;
      80             : }
      81             : } } }
      82             : 
      83             : // helper needed by SalLayout implementations as well as svx/source/dialog/svxbmpnumbalueset.cxx
      84             : VCL_DLLPUBLIC sal_UCS4 GetMirroredChar( sal_UCS4 );
      85             : VCL_DLLPUBLIC sal_UCS4 GetLocalizedChar( sal_UCS4, LanguageType );
      86             : 
      87             : enum class SystemWindowFlags {
      88             :     NOAUTOMODE    = 0x0001,
      89             :     DIALOG        = 0x0002
      90             : };
      91             : namespace o3tl
      92             : {
      93             :     template<> struct typed_flags<SystemWindowFlags> : is_typed_flags<SystemWindowFlags, 0x03> {};
      94             : }
      95             : 
      96             : typedef long (*VCLEventHookProc)( NotifyEvent& rEvt, void* pData );
      97             : 
      98             : /** An application can be notified of a number of different events:
      99             :     - TYPE_ACCEPT       - listen for connection to the application (a connection
     100             :                           string is passed via the event)
     101             :     - TYPE_UNACCEPT     - stops listening for a connection to the app (determined by
     102             :                           a connection string passed via the event)
     103             :     - TYPE_APPEAR       - brings the app to the front (i.e. makes it "appear")
     104             :     - TYPE_VERSION      - display the app version
     105             :     - TYPE_HELP         - opens a help topic (help topic passed as string)
     106             :     - TYPE_OPENHELP_URL - opens a help URL (URL passed as a string)
     107             :     - TYPE_SHOWDIALOG   - shows a dialog (dialog passed as a string)
     108             :     - TYPE_OPEN         - opens a document or group of documents (documents passed
     109             :                           as an array of strings)
     110             :     - TYPE_PRINT        - print a document or group of documents (documents passed
     111             :                           as an array of strings
     112             :     - TYPE_PRIVATE_DOSHUTDOWN - shutdown the app
     113             : */
     114             : 
     115           0 : class VCL_DLLPUBLIC ApplicationEvent
     116             : {
     117             : public:
     118             :     enum Type {
     119             :         TYPE_ACCEPT,                ///< Listen for connections
     120             :         TYPE_APPEAR,                ///< Make application appear
     121             :         TYPE_HELP,                  ///< Bring up help options (command-line help)
     122             :         TYPE_VERSION,               ///< Display product version
     123             :         TYPE_OPEN,                  ///< Open a document
     124             :         TYPE_OPENHELPURL,           ///< Open a help URL
     125             :         TYPE_PRINT,                 ///< Print document
     126             :         TYPE_PRIVATE_DOSHUTDOWN,    ///< Shutdown application
     127             :         TYPE_QUICKSTART,            ///< Start QuickStart
     128             :         TYPE_SHOWDIALOG,            ///< Show a dialog
     129             :         TYPE_UNACCEPT               ///< Stop listening for connections
     130             :     };
     131             : 
     132             :     /** Explicit constructor for ApplicationEvent.
     133             : 
     134             :      @attention TYPE_APPEAR, TYPE_VERSION, TYPE_PRIVATE_DOSHUTDOWN and
     135             :         TYPE_QUICKSTART are the \em only events that don't need to include
     136             :         a data string with the event. No other events should use this
     137             :         constructor!
     138             :     */
     139           0 :     explicit ApplicationEvent(Type type): aEvent(type)
     140             :     {
     141             :         assert(
     142             :             type == TYPE_APPEAR || type == TYPE_VERSION
     143             :             || type == TYPE_PRIVATE_DOSHUTDOWN || type == TYPE_QUICKSTART);
     144           0 :     }
     145             : 
     146             :     /** Constructor for ApplicationEvent, accepts a string for the data
     147             :      associated with the event.
     148             : 
     149             :      @attention TYPE_ACCEPT, TYPE_HELP, TYPE_OPENHELPURL, TYPE_SHOWDIALOG
     150             :         and TYPE_UNACCEPT are the \em only events that accept a single
     151             :         string as event data. No other events should use this constructor!
     152             :     */
     153           0 :     ApplicationEvent(Type type, OUString const & data): aEvent(type)
     154             :     {
     155             :         assert(
     156             :             type == TYPE_ACCEPT || type == TYPE_HELP || type == TYPE_OPENHELPURL
     157             :             || type == TYPE_SHOWDIALOG || type == TYPE_UNACCEPT);
     158           0 :         aData.push_back(data);
     159           0 :     }
     160             : 
     161             :     /** Constructor for ApplicationEvnet, accepts an array of strings for
     162             :      the data associated with the event.
     163             : 
     164             :      @attention TYPE_OPEN and TYPE_PRINT can apply to multiple documents,
     165             :         and are the \em only events that accept an array of strings. No other
     166             :         events should use this constructor.
     167             :     */
     168             :     ApplicationEvent(Type type, std::vector<OUString> const & data):
     169             :         aEvent(type), aData(data)
     170             :     {
     171             :         assert(type == TYPE_OPEN || type == TYPE_PRINT);
     172             :     }
     173             : 
     174             :     /** Get the type of event.
     175             : 
     176             :      @returns The type of event.
     177             :     */
     178           0 :     Type GetEvent() const
     179             :     {
     180           0 :         return aEvent;
     181             :     }
     182             : 
     183             :     /** Gets the application event's data string.
     184             : 
     185             :      @attention The \em only events that need a single string TYPE_ACCEPT,
     186             :         TYPE_HELP, TYPE_OPENHELPURL, TYPE_SHOWDIALOG and TYPE_UNACCEPT
     187             : 
     188             :      @returns The event's data string.
     189             :     */
     190           0 :     OUString GetStringData() const
     191             :     {
     192             :         assert(
     193             :             aEvent == TYPE_ACCEPT || aEvent == TYPE_HELP
     194             :             || aEvent == TYPE_OPENHELPURL || aEvent == TYPE_SHOWDIALOG
     195             :             || aEvent == TYPE_UNACCEPT);
     196             :         assert(aData.size() == 1);
     197           0 :         return aData[0];
     198             :     }
     199             : 
     200             :     /** Gets the event's array of strings.
     201             : 
     202             :      @attention The \em only events that need an array of strings
     203             :         are TYPE_OPEN and TYPE_PRINT.
     204             :     */
     205           0 :     std::vector<OUString> const & GetStringsData() const
     206             :     {
     207             :         assert(aEvent == TYPE_OPEN || aEvent == TYPE_PRINT);
     208           0 :         return aData;
     209             :     }
     210             : 
     211             : private:
     212             :     Type aEvent;
     213             :     std::vector<OUString> aData;
     214             : };
     215             : 
     216             : /**
     217             :  @brief Base class used mainly for the LibreOffice Desktop class.
     218             : 
     219             :  The Application class is a base class mainly used by the Desktop
     220             :  class. It is really meant to be subclassed, and the Main() function
     221             :  should be overridden. Many of the ImplSVData members should be
     222             :  moved to this class.
     223             : 
     224             :  The reason Application exists is because the VCL used to be a
     225             :  standalone framework, long since abandoned by anything other than
     226             :  our application.
     227             : 
     228             :  @see   Desktop, ImplSVData
     229             :  */
     230             : class VCL_DLLPUBLIC Application
     231             : {
     232             : public:
     233             :     enum DialogCancelMode {
     234             :         DIALOG_CANCEL_OFF,      ///< do not automatically cancel dialogs
     235             :         DIALOG_CANCEL_SILENT,   ///< silently cancel any dialogs
     236             :         DIALOG_CANCEL_FATAL     ///< cancel any dialogs by std::abort
     237             :     };
     238             : 
     239             :     /** @name Initialization
     240             :         The following functions perform initialization and deinitialization
     241             :         of the application.
     242             :     */
     243             :     ///@{
     244             : 
     245             :     /** Default constructor for Application class.
     246             : 
     247             :     Initializes the LibreOffice global instance data structure if needed,
     248             :     and then sets itself to be the Application class. Also initializes any
     249             :     platform specific data structures.
     250             : 
     251             :     @attention The initialization of the application itself is done in Init()
     252             : 
     253             :     @see    InitSalData is implemented by platform specific code.
     254             :     */
     255             :                                 Application();
     256             : 
     257             :     /** Virtual destructor for Application class.
     258             : 
     259             :      Deinitializes the LibreOffice global instance data structure, then
     260             :      deinitializes any platform specific data structures.
     261             : 
     262             :      @see   ImplDeInitSVData deinitializes the global instance data,
     263             :             DeInitSalData is implemented by platform specific code
     264             :     */
     265             :     virtual                     ~Application();
     266             : 
     267             :     /** Initialize the application itself.
     268             : 
     269             :      @attention Note that the global data structures and platform specific
     270             :         initialization is done in the constructor.
     271             : 
     272             :      @see InitFinished, DeInit
     273             :     */
     274             :     virtual void                Init();
     275             : 
     276             :     /** Finish initialization of the application.
     277             : 
     278             :      @see Init, DeInit
     279             :     */
     280             :     virtual void                InitFinished();
     281             : 
     282             :     /** Deinitialized the application itself.
     283             : 
     284             :      @attention Note that the global data structures and platform specific
     285             :          deinitialization is done in the destructor.
     286             : 
     287             :      @see Init, InitFinished
     288             :     */
     289             :     virtual void                DeInit();
     290             : 
     291             :     ///@}
     292             : 
     293             :     /** @brief Pure virtual entrypoint to the application.
     294             : 
     295             :      Main() is the pure virtual entrypoint to your application. You
     296             :      inherit your class from Application and subclass this function to
     297             :      implement an application.
     298             : 
     299             :      The Main() function does not pass in command line parameters,
     300             :      you must use the functions GetCommandLineParamCount() and
     301             :      GetCommandLineParam() to get these values as these are platform
     302             :      independent ways of getting the command line (use GetAppFileName()
     303             :      to get the invoked executable filename).
     304             : 
     305             :      Once in this function, you create windows, etc. then call on
     306             :      Execute() to start the application's main event loop.
     307             : 
     308             :      An example code snippet follows (it won't compile, this just gives the
     309             :      general flavour of the framework and is adapted from an old HelloWorld
     310             :      example program that Star Division used to provide as part of their
     311             :      library).
     312             : 
     313             :      \code{.cpp}
     314             :         class TheApplication : public Application
     315             :         {
     316             :             public:
     317             :                 virtual void Main();
     318             :         };
     319             : 
     320             :         class TheWindow : public WorkWindow
     321             :         {
     322             :             public:
     323             :                 TheWindow(vcl::Window *parent, WinBits windowStyle) :
     324             :                         WorkWindow(parent, windowStyle) {}
     325             : 
     326             :                 virtual void Paint(const Rectangle &);
     327             :         };
     328             : 
     329             :         void TheWindow::Paint(const Rectangle&)
     330             :         {
     331             :                 DrawText(Point(100,100), String("Hello World!"));
     332             :         }
     333             : 
     334             :         void TheApplication::Main()
     335             :         {
     336             :                 TheWindow aWindow(NULL, WB_APP | WB_STDWORK);
     337             :                     aWindow.Show();
     338             :                         Execute();
     339             :         }
     340             : 
     341             :         TheApplication anApplication;
     342             :     \endcode
     343             : 
     344             :     Some examples in the source tree can be found here:
     345             : 
     346             :     vcl/workben/svdem.cxx
     347             : 
     348             :     This is an example of how to use the Application and WorkWindow. Unfortunately, it
     349             :     no longer compiles.
     350             : 
     351             :     vcl/fpicker/test/svdem.cxx
     352             :     */
     353             :     virtual int                 Main();
     354             : 
     355             :     /** Exit from the application
     356             : 
     357             :      @returns true if exited successfully, false if not able to fully exit
     358             :     */
     359             :     virtual bool                QueryExit();
     360             : 
     361             :     /** @name Change Notification Functions
     362             : 
     363             :         Functions that notify when changes occur in the application.
     364             :     */
     365             :     ///@{
     366             : 
     367             :     /** Notify all windows that the application has changed data.
     368             : 
     369             :      @param rDCEvt     Reference to a DataChangedEvent object
     370             : 
     371             :      @see DataChanged
     372             :     */
     373             :     static void                 NotifyAllWindows( DataChangedEvent& rDCEvt );
     374             : 
     375             :     ///@}
     376             : 
     377             :     /** @name Command Line Processing
     378             : 
     379             :         Command line processing is done via the following functions. They
     380             :         give the number of parameters, the parameters themselves and a way
     381             :         to get the name of the invoking application.
     382             :     */
     383             : 
     384             :     ///@{
     385             : 
     386             :     /** Gets the number of command line parameters passed to the application
     387             : 
     388             :      @return sal_uInt16 - the number of parameters
     389             : 
     390             :      @see GetCommandLineParam, GetAppFileName
     391             :     */
     392             :     static sal_uInt16           GetCommandLineParamCount();
     393             : 
     394             :     /** Gets a particular command line parameter
     395             : 
     396             :      @param  nParam      The index of the parameter to return.
     397             : 
     398             :      @return The command line parameter as an OUString
     399             : 
     400             :      @see GetCommandLineParamCount, GetAppFileName
     401             :     */
     402             :     static OUString             GetCommandLineParam( sal_uInt16 nParam );
     403             : 
     404             :     /** Get the name of the file used to start the application
     405             : 
     406             :      @return The filename as an OUString
     407             : 
     408             :      @see GetCommandLineParamCount, GetCommandLineParam
     409             :     */
     410             :     static OUString             GetAppFileName();
     411             : 
     412             :     ///@}
     413             : 
     414             :     /** @name Error Handling
     415             : 
     416             :         \em Very rudimentary error handling is done by these
     417             :         functions.
     418             : 
     419             :         @{
     420             :     */
     421             : 
     422             :     /** Handles an error code.
     423             : 
     424             :      @remark This is not actually an exception. It merely takes an
     425             :         error code, then in most cases aborts. The list of exception
     426             :         identifiers can be found at include/vcl/apptypes.hxx - each
     427             :         one starts with EXC_*
     428             : 
     429             :      @param nError      The error code identifier
     430             : 
     431             :      @returns sal_uInt16 value - if it is 0, then the error wasn't handled.
     432             : 
     433             :      @see Abort
     434             :     */
     435             :     virtual sal_uInt16          Exception( sal_uInt16 nError );
     436             : 
     437             :     /** Ends the program prematurely with an error message.
     438             : 
     439             :      If the \code --norestore \endcode command line argument is given (assuming
     440             :      this process is run by developers who are interested in cores,
     441             :      vs. end users who are not) then it does a coredump.
     442             : 
     443             :      @param rErrorText  The error message to report.
     444             : 
     445             :      @see Exception
     446             :     */
     447             :     static void                 Abort( const OUString& rErrorText );
     448             : 
     449             :     ///@}
     450             : 
     451             :     /** @name Event Loop Functions
     452             : 
     453             :         Functions that handle the LibreOffice main event loop are here,
     454             :         including a global lock called the Solar Mutex.
     455             :     */
     456             :     ///@{
     457             : 
     458             :     /** Run the main event processing loop until it is quit by Quit().
     459             : 
     460             :      @see Quit, Reschedule, Yield, EndYield, GetSolarMutex,
     461             :           GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
     462             :           EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
     463             :           RemovePostYieldListener
     464             :     */
     465             :     static void                 Execute();
     466             : 
     467             :     /** Quit the program
     468             : 
     469             :      @see Execute, Reschedule, Yield, EndYield, GetSolarMutex,
     470             :           GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
     471             :           EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
     472             :           RemovePostYieldListener
     473             :     */
     474             :     static void                 Quit();
     475             : 
     476             :     /** Attempt to reschedule in processing of current event(s)
     477             : 
     478             :      @param bAllEvents  If set to true, then try to process all the
     479             :         events. If set to false, then only process the current
     480             :         event. Defaults to false.
     481             : 
     482             :      @see Execute, Quit, Yield, EndYield, GetSolarMutex,
     483             :           GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
     484             :           EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
     485             :           RemovePostYieldListener
     486             :      */
     487             :     static void                 Reschedule( bool bAllEvents = false );
     488             : 
     489             :     /** Allow processing of the next event.
     490             : 
     491             :      @see Execute, Quit, Reschedule, EndYield, GetSolarMutex,
     492             :           GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
     493             :           EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
     494             :           RemovePostYieldListener
     495             :     */
     496             :     static void                 Yield();
     497             : 
     498             :     /**
     499             : 
     500             :      @see Execute, Quit, Reschedule, Yield, GetSolarMutex,
     501             :           GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
     502             :           EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
     503             :           RemovePostYieldListener
     504             :     */
     505             :     static void                 EndYield();
     506             : 
     507             :     /** @brief Get the Solar Mutex for this thread.
     508             : 
     509             :      Get the Solar Mutex that prevents other threads from accessing VCL
     510             :      concurrently.
     511             : 
     512             :      @returns SolarMutex reference
     513             : 
     514             :      @see Execute, Quit, Reschedule, Yield, EndYield,
     515             :           GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
     516             :           EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
     517             :           RemovePostYieldListener
     518             :     */
     519             :     static comphelper::SolarMutex& GetSolarMutex();
     520             : 
     521             :     /** Get the main thread ID.
     522             : 
     523             :      @returns oslThreadIdentifier that contains the thread ID
     524             : 
     525             :      @see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
     526             :           ReleaseSolarMutex, AcquireSolarMutex,
     527             :           EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
     528             :           RemovePostYieldListener
     529             :     */
     530             :     static oslThreadIdentifier  GetMainThreadIdentifier();
     531             : 
     532             :     /** @brief Release Solar Mutex(es) for this thread
     533             : 
     534             :      Release the Solar Mutex(es) that prevents other threads from accessing
     535             :      VCL concurrently.
     536             : 
     537             :      @returns The number of mutexes that were acquired by this thread.
     538             : 
     539             :      @see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
     540             :           GetMainThreadIdentifier, AcquireSolarMutex,
     541             :           EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
     542             :           RemovePostYieldListener
     543             :     */
     544             :     static sal_uLong            ReleaseSolarMutex();
     545             : 
     546             :     /** @brief Acquire Solar Mutex(es) for this thread.
     547             : 
     548             :      Acquire the Solar Mutex(es) that prevents other threads from accessing
     549             :      VCL concurrently.
     550             : 
     551             :      @see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
     552             :           GetMainThreadIdentifier, ReleaseSolarMutex,
     553             :           EnableNoYieldMode, DisableNoYieldMode, AddPostYieldListener,
     554             :           RemovePostYieldListener
     555             :     */
     556             :     static void                 AcquireSolarMutex( sal_uLong nCount );
     557             : 
     558             :     /** @brief Enables "no yield" mode
     559             : 
     560             :      "No yield" mode prevents Yield() from waiting for events.
     561             : 
     562             :      @remarks This was originally implemented in OOo bug 98792 to improve
     563             :         Impress slideshows.
     564             : 
     565             :      @see DisableNoYieldMode, Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
     566             :           GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
     567             :           DisableNoYield, AddPostYieldListener, RemovePostYieldListener
     568             :     */
     569             :     static void                 EnableNoYieldMode();
     570             : 
     571             :     /** @brief Disables "no yield" mode
     572             : 
     573             :      "No yield" mode prevents Yield() from waiting for events.
     574             : 
     575             :      @remarks This was originally implemented in OOo bug 98792 to improve
     576             :         Impress slideshows.
     577             : 
     578             :      @see EnableNoYieldMode, Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
     579             :           GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
     580             :           EnableNoYield, AddPostYieldListener, RemovePostYieldListener
     581             :     */
     582             : 
     583             :     static void                 DisableNoYieldMode();
     584             : 
     585             :     /** Add a listener for yield events
     586             : 
     587             :      @param  i_rListener     Listener to add
     588             : 
     589             :      @see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
     590             :           GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
     591             :           EnableNoYieldMode, DisableNoYieldMode, RemovePostYieldListener
     592             :     */
     593             :     static void                 AddPostYieldListener( const Link<>& i_rListener );
     594             : 
     595             :     /** Remove listener for yield events
     596             : 
     597             :      @param  i_rListener     Listener to remove
     598             : 
     599             :      @see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex,
     600             :           GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex,
     601             :           AddPostYieldListener, EnableNoYieldMode, DisableNoYieldMode
     602             :     */
     603             :     static void                 RemovePostYieldListener( const Link<>& i_rListener );
     604             : 
     605             : 
     606             :     /** Queries whether the application is in "main", i.e. not yet in
     607             :         the event loop
     608             : 
     609             :      @returns   true if in main, false if not in main
     610             : 
     611             :      @see IsInExecute, IsInModalMode
     612             :     */
     613             :     static bool                 IsInMain();
     614             : 
     615             :     /** Queries whether the application is in the event loop
     616             : 
     617             :      @returns   true if in the event loop, false if not
     618             : 
     619             :      @see IsInMain, IsInModalMode
     620             :     */
     621             :     static bool                 IsInExecute();
     622             : 
     623             :     /** Queries whether application has a modal dialog active.
     624             : 
     625             :      @returns   true if a modal dialog is active, false if not
     626             : 
     627             :      @see IsInMain, IsInExecute
     628             :     */
     629             :     static bool                 IsInModalMode();
     630             : 
     631             :     /** Return how many events are being dispatched.
     632             : 
     633             :      @returns   the number of events currently being dispatched
     634             :     */
     635             :     static sal_uInt16           GetDispatchLevel();
     636             : 
     637             :     /** Determine if there are any pending input events.
     638             : 
     639             :      @param     nType   input identifier, defined in include/vcl/apptypes.hxx
     640             :                         The default is VCL_INPUT_ANY.
     641             : 
     642             :      @returns   true if there are pending events, false if not.
     643             : 
     644             :      @see GetLastInputInterval
     645             :     */
     646             :     static bool                 AnyInput( VclInputFlags nType = VCL_INPUT_ANY );
     647             : 
     648             :     /** The interval from the last time that input was received.
     649             : 
     650             :      @returns   system ticks - last input time
     651             : 
     652             :      @see AnyInput
     653             :     */
     654             :     static sal_uInt64           GetLastInputInterval();
     655             : 
     656             :     ///@}
     657             : 
     658             :     /* Determines if the UI is captured.
     659             : 
     660             :      The UI is considered captured if a system dialog is open (e.g. printer setup),
     661             :      a floating window, menu or toolbox dropdown is open, or a window has been
     662             :      captured by the mouse.
     663             : 
     664             :      @returns   true if UI is captured, false if not
     665             :      */
     666             :     static bool                 IsUICaptured();
     667             : 
     668             :     /** @name Settings
     669             : 
     670             :         The following functions set system settings (e.g. tab color, etc.). There are functions
     671             :         that set settings objects, and functions that set and get the actual system settings for
     672             :         the application.
     673             :     */
     674             :     ///@{
     675             : 
     676             :     /** Sets user settings in settings object to override system settings
     677             : 
     678             :      The system settings that can be overridden are:
     679             :         - window dragging options (on or off, including live scrolling!)
     680             :         - style settings (e.g. checkbox color, border color, 3D colors,
     681             :           button rollover colors, etc.)
     682             :         - mouse settings
     683             :         - menu options, including the mouse follows the menu and whether menu
     684             :           icons are used
     685             : 
     686             :      @param      rSettings      Reference to the settings object to change.
     687             : 
     688             :      @see MergeSystemSettings, SetSettings, GetSettings
     689             :     */
     690             :     virtual void                OverrideSystemSettings( AllSettings& rSettings );
     691             : 
     692             :     /** Set the settings object to the platform/desktop environment system
     693             :      settings.
     694             : 
     695             :      @param     rSettings       Reference to the settings object to change.
     696             : 
     697             :      @see OverrideSystemSettings, SetSettings, GetSettings
     698             :     */
     699             :     static void                 MergeSystemSettings( AllSettings& rSettings );
     700             : 
     701             :     /** Sets the application's settings and notifies all windows of the
     702             :      change.
     703             : 
     704             :      @param     rSettings       const reference to settings object used to
     705             :                                 change the application's settings.
     706             : 
     707             :      @see OverrideSystemSettings, MergeSystemSettings, GetSettings
     708             :     */
     709             :     static void                 SetSettings( const AllSettings& rSettings );
     710             : 
     711             :     /** Gets the application's settings. If the application hasn't initialized
     712             :      it's settings, then it does so (lazy initialization).
     713             : 
     714             :      @returns AllSettings instance that contains the current settings of the
     715             :         application.
     716             : 
     717             :      @see OverrideSystemSettings, MergeSystemSettings, SetSettings
     718             :     */
     719             :     static const AllSettings&   GetSettings();
     720             : 
     721             :     /** Get the application's locale data wrapper.
     722             : 
     723             :      @returns reference to a LocaleDataWrapper object
     724             :     */
     725             :     static const LocaleDataWrapper& GetAppLocaleDataWrapper();
     726             : 
     727             :     ///@}
     728             : 
     729             :     /** @name Event Listeners/Handlers
     730             : 
     731             :         A set of event listeners and callers. Note that in this code there is
     732             :         platform specific functions - namely for zoom and scroll events.
     733             :     */
     734             :     ///@{
     735             : 
     736             : 
     737             :     /** Call on all event hooks
     738             : 
     739             :      @param rEvt                Reference to the notification event to send
     740             :                                 to the event hook.
     741             : 
     742             :      @return If any of the event hooks called upon fail with a non-zero
     743             :          status, then it stops processing any more event hooks and returns
     744             :          the error code as a long.
     745             : 
     746             :     */
     747             :     static long                 CallEventHooks( NotifyEvent& rEvt );
     748             : 
     749             :     /** Add a VCL event listener to the application. If no event listener exists,
     750             :      then initialize the application's event listener with a new one, then add
     751             :      the event listener.
     752             : 
     753             :      @param     rEventListener  Const reference to the event listener to add.
     754             : 
     755             :      @see RemoveEventListener, AddKeyListener, RemoveKeyListener
     756             :     */
     757             :     static void                 AddEventListener( const Link<>& rEventListener );
     758             : 
     759             :     /** Remove a VCL event listener from the application.
     760             : 
     761             :      @param     rEventListener  Const refernece to the event listener to be removed
     762             : 
     763             :      @see AddEventListener, AddKeyListener, RemoveKeyListener
     764             :     */
     765             :     static void                 RemoveEventListener( const Link<>& rEventListener );
     766             : 
     767             :     /** Add a keypress listener to the application. If keypress listener exists,
     768             :      then initialize the application's keypress event listener with a new one, then
     769             :      add the keypress listener.
     770             : 
     771             :      @param     rKeyListener    Const reference to the keypress event listener to add
     772             : 
     773             :      @see AddEventListener, RemoveEventListener, RemoveKeyListener
     774             :     */
     775             :     static void                 AddKeyListener( const Link<>& rKeyListener );
     776             : 
     777             :     /** Remove a keypress listener from the application.
     778             : 
     779             :      @param     rKeyListener    Const reference to the keypress event listener to be removed
     780             : 
     781             :      @see AddEventListener, RemoveEventListener, AddKeyListener
     782             :     */
     783             :     static void                 RemoveKeyListener( const Link<>& rKeyListener );
     784             : 
     785             :     /** Send event to all VCL application event listeners
     786             : 
     787             :      @param     nEvent          Event ID
     788             :      @param     pWin            Pointer to window to send event
     789             :      @param     pData           Pointer to data to send with event
     790             : 
     791             :      @see ImplCallEventListeners(VclSimpleEvent* pEvent)
     792             :     */
     793             :     static void                 ImplCallEventListeners( sal_uLong nEvent, vcl::Window* pWin, void* pData );
     794             : 
     795             :     /** Send event to all VCL application event listeners
     796             : 
     797             :      @param     pEvent          Pointer to VclSimpleEvent
     798             : 
     799             :      @see ImplCallEventListeners(sal_uLong nEvent, Windows* pWin, void* pData);
     800             :     */
     801             :     static void                 ImplCallEventListeners( VclSimpleEvent* pEvent );
     802             : 
     803             :     /** Handle keypress event
     804             : 
     805             :      @param     nEvent          Event ID for keypress
     806             :      @param     pWin            Pointer to window that receives the event
     807             :      @param     pKeyEvent       Received key event
     808             : 
     809             :      @see PostKeyEvent
     810             :     */
     811             :     static bool                 HandleKey( sal_uLong nEvent, vcl::Window *pWin, KeyEvent* pKeyEvent );
     812             : 
     813             :     /** Send keypress event
     814             : 
     815             :      @param     nEvent          Event ID for keypress
     816             :      @param     pWin            Pointer to window to which the event is sent
     817             :      @param     pKeyEvent       Key event to send
     818             : 
     819             :      @see HandleKey
     820             :     */
     821             :     static ImplSVEvent *        PostKeyEvent( sal_uLong nEvent, vcl::Window *pWin, KeyEvent* pKeyEvent );
     822             : 
     823             :     /** Send mouse event
     824             : 
     825             :      @param     nEvent          Event ID for mouse event
     826             :      @param     pWin            Pointer to window to which the event is sent
     827             :      @param     pKeyEvent       Mouse event to send
     828             :     */
     829             :     static ImplSVEvent *        PostMouseEvent( sal_uLong nEvent, vcl::Window *pWin, MouseEvent* pMouseEvent );
     830             : 
     831             :     /** Send zoom event
     832             : 
     833             :      Experimental work in progress. Available only for iOS and Android, and unclear whether actually
     834             :      is needed now with tiled rendering.
     835             : 
     836             :      @param     nEvent          Event ID for zoom event
     837             :      @param     pWin            Pointer to window to which the event is sent
     838             :      @param     pZoomEvent      Zoom event to send
     839             :     */
     840             :     static ImplSVEvent *        PostZoomEvent( sal_uLong nEvent, vcl::Window *pWin, ZoomEvent* pZoomEvent );
     841             : 
     842             :     /* Send scroll event
     843             : 
     844             :      Experimental work in progress. Available only for iOS and Android, and unclear whether actually
     845             :      is needed now with tiled rendering.
     846             : 
     847             :      @param      nEvent          Event ID for scroll event
     848             :      @param      pWin            Pointer to window to which the event is sent
     849             :      @param      pScrollEvent    Scroll event to send
     850             :     */
     851             :     static ImplSVEvent *         PostScrollEvent( sal_uLong nEvent, vcl::Window *pWin, ScrollEvent* pScrollEvent );
     852             : 
     853             :     /** Remove mouse and keypress events from a window... any also zoom and scroll events
     854             :      if the platform supports it.
     855             : 
     856             :      @param     pWin            Window to remove events from
     857             : 
     858             :      @see HandleKey, PostKeyEvent, PostMouseEvent, PostZoomEvent, PostScrollEvent
     859             :     */
     860             :     static void                 RemoveMouseAndKeyEvents( vcl::Window *pWin );
     861             : 
     862             :     /** Post a user event to the default window.
     863             : 
     864             :      User events allow for the deferral of work to later in the main-loop - at idle.
     865             : 
     866             :      @param     rLink           Link to event callback function
     867             :      @param     pCaller         Pointer to data sent to the event by the caller. Optional.
     868             :      @param     bReferenceLink  If true - hold a VclPtr<> reference on the Link's instance.
     869             : 
     870             :      @return the event ID used to post the event.
     871             :     */
     872             :     static ImplSVEvent * PostUserEvent( const Link<>& rLink, void* pCaller = NULL,
     873             :                                         bool bReferenceLink = false );
     874             : 
     875             :     /** Remove user event based on event ID
     876             : 
     877             :      @param     nUserEvent      User event to remove
     878             :     */
     879             :     static void                 RemoveUserEvent( ImplSVEvent * nUserEvent );
     880             : 
     881             :     /** Insert an idle handler into the application.
     882             : 
     883             :      If the idle event manager doesn't exist, then initialize it.
     884             : 
     885             :      @param     rLink           const reference to the idle handler
     886             :      @param     nPrio           The priority of the idle handler - idle handlers of a higher
     887             :                                 priority will be processed before this handler.
     888             : 
     889             :      @return true if the handler was inserted successfully, false if it couldn't be inserted.
     890             :     */
     891             :     static bool                 InsertIdleHdl( const Link<>& rLink, sal_uInt16 nPriority );
     892             : 
     893             :     /** Remove an idle handler from the application.
     894             : 
     895             :      @param     rLink           const reference to the idle handler to remove
     896             :     */
     897             :     static void                 RemoveIdleHdl( const Link<>& rLink );
     898             : 
     899             :     /*** Get the DisplayConnection.
     900             : 
     901             :      It is a reference to XDisplayConnection, which allows toolkits to send display
     902             :      events to the application.
     903             : 
     904             :      @returns UNO reference to an object that implements the css:awt:XDisplayConnection
     905             :         interface.
     906             :     */
     907             :     static css::uno::Reference< css::awt::XDisplayConnection > GetDisplayConnection();
     908             : 
     909             :     /** @deprecated AppEvent is used only in the Desktop class now. However, it is
     910             :      intended to notify the application that an event has occurred. It was in oldsv.cxx,
     911             :      but is still needed by a number of functions.
     912             : 
     913             :      @param     rAppEvent       const reference to ApplicationEvent event
     914             :     */
     915             :     virtual void                AppEvent( const ApplicationEvent& rAppEvent );
     916             : 
     917             :     ///@}
     918             : 
     919             :     /** @name Application Window Functions
     920             : 
     921             :         Functions that deal with the application's windows
     922             :     */
     923             :     ///@{
     924             : 
     925             :     /** Get the main application window.
     926             : 
     927             :      @remark the main application window (or App window) has a style of WB_APP,
     928             :         there can only be on WorkWindow with this style, if a dialog or floating
     929             :         window cannot find a parent, then the parent becomes the app window.
     930             : 
     931             :         It also becomes the "default window", is used for help, is a fallback if
     932             :         the application has no name, and a number of other things.
     933             : 
     934             :      returns Pointer to main application window.
     935             : 
     936             :      @see GetFocusWindow, GetDefaultDevice
     937             :     */
     938             :     static WorkWindow*          GetAppWindow();
     939             : 
     940             :     /** Get the currently focussed window.
     941             : 
     942             :      @returns Pointer to focused window.
     943             : 
     944             :      @see GetAppWindow, GetDefaultDevice
     945             :     */
     946             :     static vcl::Window*              GetFocusWindow();
     947             : 
     948             :     /** Get the default "device" (in this case the default window).
     949             : 
     950             :      @returns Pointer to an OutputDevice. However, it is a Window object -
     951             :              Window class subclasses OutputDevice.
     952             : 
     953             :      @see GetAppWindow, GetFocusWindow
     954             :     */
     955             :     static OutputDevice*        GetDefaultDevice();
     956             : 
     957             :     /** Get the first top-level window of the application.
     958             : 
     959             :      @returns Pointer to top-level window (a Window object)
     960             : 
     961             :      @see GetNextTopLevelWindow, GetTopWindowCount, GetTopWindow,
     962             :           GetActiveTopWindow
     963             :     */
     964             :     static vcl::Window*              GetFirstTopLevelWindow();
     965             : 
     966             :     /** Get the next top level window.
     967             : 
     968             :      @param     pWindow     Pointer to Window object you wish to get the next
     969             :                             window from.
     970             : 
     971             :      @returns Pointer to next top window.
     972             :     */
     973             :     static vcl::Window*              GetNextTopLevelWindow( vcl::Window* pWindow );
     974             : 
     975             :     /** Return the number of top-level windows being used by the application
     976             : 
     977             :      @returns the number of top-level windows
     978             : 
     979             :      @see GetFirstTopLevelWindow, GetNextTopLevelWindow, GetTopWindow,
     980             :           GetActiveTopWindow
     981             : 
     982             :     */
     983             :     static long                 GetTopWindowCount();
     984             : 
     985             :     /** Get the nth top window.
     986             : 
     987             :      @remark Top windows are actually implemented in a one-way linked list.
     988             :          This iterates through top level windows n times.
     989             : 
     990             :      @param    nIndex      The index of the top-level window
     991             : 
     992             :      @returns The nth top-level window of the application
     993             : 
     994             :      @see GetFirstTopLevelWindow, GetNextTopLevelWindow, GetTopWindowCount,
     995             :           GetActiveTopWindow
     996             :     */
     997             :     static vcl::Window*              GetTopWindow( long nIndex );
     998             : 
     999             :     /** Get the "active" top window.
    1000             : 
    1001             :      An "active" top window is one that has a child window that has the
    1002             :      application's focus.
    1003             : 
    1004             :      @returns the active top window
    1005             : 
    1006             :      @see GetFirstTopLevelWindow, GetNextTopLevelWindow, GetTopWindowCount,
    1007             :           GetTopWindow
    1008             :     */
    1009             :     static vcl::Window*              GetActiveTopWindow();
    1010             : 
    1011             :     ///@}
    1012             : 
    1013             :     /** Set the application's name.
    1014             : 
    1015             :      @param     rUniqueName     What to set the application name to
    1016             : 
    1017             :      @see       GetAppName
    1018             :     */
    1019             :     static void                 SetAppName( const OUString& rUniqueName );
    1020             : 
    1021             : 
    1022             :     /** @name Application Name, Branding
    1023             :     */
    1024             :     ///@{
    1025             : 
    1026             :     /** Get the application's name.
    1027             : 
    1028             :      @returns The application name.
    1029             :     */
    1030             :     static OUString             GetAppName();
    1031             : 
    1032             :     /** Load a localized branding PNG file as a bitmap.
    1033             : 
    1034             :      @param     pName           Name of the bitmap to load.
    1035             :      @param     rBitmap         Reference to BitmapEx object to load PNG into
    1036             : 
    1037             :      @returns true if the PNG could be loaded, otherwise returns false.
    1038             :     */
    1039             :     static bool                 LoadBrandBitmap (const char* pName, BitmapEx &rBitmap);
    1040             : 
    1041             :     ///@}
    1042             : 
    1043             :     /** @name Display and Screen
    1044             :     */
    1045             :     ///@{
    1046             : 
    1047             :     /** Set the default name of the application for message dialogs and printing.
    1048             : 
    1049             :      @param     rDisplayName    const reference to string to set the Display name to.
    1050             : 
    1051             :      @see GetDisplayName
    1052             :     */
    1053             :     static void                 SetDisplayName( const OUString& rDisplayName );
    1054             : 
    1055             :     /** Get the default name of the application for messag dialogs and printing.
    1056             : 
    1057             :      @returns The display name of the application.
    1058             :     */
    1059             :     static OUString             GetDisplayName();
    1060             : 
    1061             :     /** Get the number of screens available for the display.
    1062             : 
    1063             :      @returns The number of screens available.
    1064             : 
    1065             :      @see GetScreenPosSizePixel
    1066             :     */
    1067             :     static unsigned int         GetScreenCount();
    1068             : 
    1069             :     /** Get a screen's rectangular area.
    1070             : 
    1071             :      @param     nScreen         The number of the screen requested.
    1072             : 
    1073             :      @returns The area of the screen in a Rectangle object.
    1074             : 
    1075             :      @see GetScreenCount
    1076             :     */
    1077             :     static Rectangle            GetScreenPosSizePixel( unsigned int nScreen );
    1078             : 
    1079             :     /** Determines if the screens that make up a display are separate or
    1080             :      form one large display area.
    1081             : 
    1082             :      @returns true when screens form up one large display area windows can be
    1083             :         moved between single screens (e.g. Xserver with Xinerama, Windows)
    1084             :         and false when different screens are separate and windows cannot be moved
    1085             :         between them (e.g. Xserver with multiple screens)
    1086             : 
    1087             :      @see GetBestScreen, GetDisplayBuiltInScreen
    1088             :     */
    1089             :     static bool                 IsUnifiedDisplay();
    1090             : 
    1091             :     /** Get the "best" screen.
    1092             : 
    1093             :      @returns If IsUnifiedDisplay() == true the return value will be
    1094             :        nearest screen of the target rectangle.
    1095             : 
    1096             :        In case of IsUnifiedDisplay() == false the return value
    1097             :        will always be GetDisplayDefaultScreen().
    1098             : 
    1099             :      @see IsUnifiedDisplay, GetDisplayBuiltInScreen
    1100             :     */
    1101             :     SAL_DLLPRIVATE static unsigned int GetBestScreen( const Rectangle& );
    1102             : 
    1103             :     /** Get the built-in screen.
    1104             : 
    1105             :      @return
    1106             :        This returns the LCD screen number for a laptop, or the primary
    1107             :        external VGA display for a desktop machine - it is where a presenter
    1108             :        console should be rendered if there are other (non-built-in) screens
    1109             :        present.
    1110             : 
    1111             :      @see IsUnifiedDisplay, GetBestScreen
    1112             :     */
    1113             :     static unsigned int         GetDisplayBuiltInScreen();
    1114             : 
    1115             :     /** Get the display's external screen.
    1116             : 
    1117             :      Practically, this means - Get the screen we should run a presentation on.
    1118             : 
    1119             :      @returns 0 or 1 currently, will fallback to the first available screen if
    1120             :         there are more than one external screens. May be changed in the future.
    1121             :     */
    1122             :     static unsigned int         GetDisplayExternalScreen();
    1123             : 
    1124             :     ///@}
    1125             : 
    1126             :     /** @name Accelerators and Mnemonics
    1127             : 
    1128             :      Accelerators allow a user to hold down Ctrl+key (or CMD+key on OS X)
    1129             :      combination to gain quick access to functionality.
    1130             : 
    1131             :      Mnemonics are underline letters in things like menus and dialog boxes
    1132             :      that allow a user to type in the letter to activate the menu or option.
    1133             :     */
    1134             :     ///@{
    1135             : 
    1136             :     /** Insert accelerator
    1137             : 
    1138             :      @param     pAccel          Pointer to an Accelerator object to insert
    1139             : 
    1140             :      @returns true if successful, false if otherwise
    1141             : 
    1142             :      @see RemoveAccel
    1143             :     */
    1144             :     static bool                 InsertAccel( Accelerator* pAccel );
    1145             : 
    1146             :     /** Remove accelerator
    1147             : 
    1148             :      @param     pAccel          Pointer to Accelerator object to remove
    1149             : 
    1150             :      @see InsertAccel
    1151             :     */
    1152             :     static void                 RemoveAccel( Accelerator* pAccel );
    1153             : 
    1154             :     /** Enable auto-mnemonics
    1155             : 
    1156             :      @param     bEnabled        True enables auto-mnemonics, and false disables it
    1157             : 
    1158             :      @see IsAutoMnemonicEnabled
    1159             :     */
    1160             :     static void                 EnableAutoMnemonic( bool bEnabled = true );
    1161             : 
    1162             :     /** Determines if auto-mnemonics are enabled.
    1163             : 
    1164             :      @returns True if auto-mnemonics is enabled, false if not.
    1165             : 
    1166             :      @see EnableAutoMnemonic
    1167             :     */
    1168             :     static bool                 IsAutoMnemonicEnabled();
    1169             : 
    1170             :     /** Get the number of reserved key codes used by the application.
    1171             : 
    1172             :      @returns number of reserved key codes
    1173             : 
    1174             :      @see GetReservedKeyCode
    1175             :     */
    1176             :     static sal_uLong            GetReservedKeyCodeCount();
    1177             : 
    1178             :     /** Get the reserved key code.
    1179             : 
    1180             :      @param     i               The keycode number to retrieve
    1181             : 
    1182             :      @returns Const pointer to a KeyCode object
    1183             : 
    1184             :      @see GetReservedKeyCodeCount
    1185             :     */
    1186             :     static const vcl::KeyCode*  GetReservedKeyCode( sal_uLong i );
    1187             : 
    1188             :     ///@}
    1189             : 
    1190             :     /** @name Application Help
    1191             : 
    1192             :      Deals with the help system, and "auto-help", where a user hovers a mouse above
    1193             :      a UI element and a tooltip with an explanation pops up.
    1194             :     */
    1195             :     ///@{
    1196             : 
    1197             :     /** Sets up help
    1198             : 
    1199             :      @param     pHelp           Pointer to a Help object (optional, can by NULL)
    1200             : 
    1201             :      @see GetHelp
    1202             :     */
    1203             :     static void                 SetHelp( Help* pHelp = NULL );
    1204             : 
    1205             :     /** Gets the application's help
    1206             : 
    1207             :      @returns Pointer to application's help object. Note that the application may
    1208             :         not have a help object, so it might return NULL.
    1209             : 
    1210             :      @see SetHelp
    1211             :     */
    1212             :     static Help*                GetHelp();
    1213             : 
    1214             :     /** Turns on "auto-help" (hover mouse above UI element and a tooltip with an
    1215             :      explanation pops up.
    1216             : 
    1217             :      @param     bEnabled        Enables/disables auto-help.
    1218             : 
    1219             :      @see EnableAutoHelpId
    1220             :     */
    1221             :     static void                 EnableAutoHelpId( bool bEnabled = true );
    1222             : 
    1223             :     /** Determines if auto-help is enabled or disabled.
    1224             : 
    1225             :      @return true if auto-help is enabled, false if it is disabled.
    1226             : 
    1227             :      @see EnableAutoHelpId
    1228             :     */
    1229             :     static bool                 IsAutoHelpIdEnabled();
    1230             : 
    1231             :     ///@}
    1232             : 
    1233             :     /** @name Dialogs
    1234             : 
    1235             :         @remark "Dialog cancel mode" tells a headless install whether to
    1236             :                 cancel dialogs when they appear. See the DialogCancelMode
    1237             :                 enumerator.
    1238             :     */
    1239             :     ///@{
    1240             : 
    1241             :     /** Set the default parent window for dialog boxes.
    1242             : 
    1243             :      @param     pWindow         Pointer to window that should be the default parent.
    1244             : 
    1245             :      @remark You can set pWindow to NULL, which means there \em is no default parent.
    1246             : 
    1247             :      @see GetDefDialogParent
    1248             :     */
    1249             :     static void                 SetDefDialogParent( vcl::Window* pWindow );
    1250             : 
    1251             :     /** Get the default parent window for dialog boxes.
    1252             : 
    1253             :      @remark GetDefDialogParent does all sorts of things find a useful parent
    1254             :              window for dialogs. If it can't find one (it wasn't set!) then it
    1255             :              first uses the topmost parent of the active window to avoid using
    1256             :              floating windows or other dialog boxes. If there are no active
    1257             :              windows, then it will take a random stab and choose the first visible
    1258             :              top window. Otherwise, it defaults to the desktop.
    1259             : 
    1260             :      @returns Pointer to the default window.
    1261             :     */
    1262             :     static vcl::Window*              GetDefDialogParent();
    1263             : 
    1264             : 
    1265             :     /** Gets the dialog cancel mode for headless environments.
    1266             : 
    1267             :      @return DialogCancelMode value
    1268             : 
    1269             :      @see SetDialogCancelMode, IsDialogCancelEnabled
    1270             :     */
    1271             :     static DialogCancelMode     GetDialogCancelMode();
    1272             : 
    1273             :     /** Sets the dialog cancel mode for headless environments.
    1274             : 
    1275             :      @param     mode            DialogCancel mode value
    1276             : 
    1277             :      @see GetDialogCancelMode, IsDialogCancelEnabled
    1278             :     */
    1279             :     static void                 SetDialogCancelMode( DialogCancelMode mode );
    1280             : 
    1281             :     /** Determines if dialog cancel mode is enabled.
    1282             : 
    1283             :      @returns True if dialog cancel mode is enabled, false if disabled.
    1284             : 
    1285             :      @see GetDialogCancelMode, SetDialogCancelMode
    1286             :     */
    1287             :     static bool                 IsDialogCancelEnabled();
    1288             : 
    1289             : 
    1290             :     /** Make a dialog box a system window or not.
    1291             : 
    1292             :      @param     nMode           Can be either: SystemWindowFlags::NOAUTOMODE (0x0001) or
    1293             :                                 SystemWindowFlags::DIALOG (0x0002)
    1294             : 
    1295             :      @see GetSystemWindowMode
    1296             :     */
    1297             :     static void                 SetSystemWindowMode( SystemWindowFlags nMode );
    1298             : 
    1299             :     /** Get the system window mode of dialogs.
    1300             : 
    1301             :      @returns SystemWindowFlags::NOAUTOMODE (0x0001) or SystemWindowFlags::DIALOG (0x0002)
    1302             : 
    1303             :      @see SetSystemWindowMode
    1304             :     */
    1305             :     static SystemWindowFlags    GetSystemWindowMode();
    1306             : 
    1307             : 
    1308             :     /** Set a dialog scaling factor. Used for localization.
    1309             : 
    1310             :      @param     nScale          Scaling factor
    1311             :     */
    1312             :     static void                 SetDialogScaleX( short nScale );
    1313             : 
    1314             :     ///@}
    1315             : 
    1316             :     /** @name VCL Toolkit and UNO Wrapper
    1317             : 
    1318             :       The VCL Toolkit implements the UNO XToolkit interface, which specifies a
    1319             :       factory interface for the window toolkit. It is similar to the abstract window
    1320             :       toolkit (AWT) in Java.
    1321             : 
    1322             :     */
    1323             :     ///@{
    1324             : 
    1325             :     /** Gets the VCL toolkit.
    1326             : 
    1327             :      @attention The global service manager has to be created before getting the toolkit!
    1328             : 
    1329             :      @returns UNO reference to VCL toolkit
    1330             :     */
    1331             :     static css::uno::Reference< css::awt::XToolkit > GetVCLToolkit();
    1332             : 
    1333             :     /** Get the application's UNO wrapper object.
    1334             : 
    1335             :      Note that this static function will only ever try to create UNO wrapper object once, and
    1336             :      if it fails then it will not ever try again, even if the function is called multiple times.
    1337             : 
    1338             :      @param     bCreateIfNotExists  Create the UNO wrapper object if it doesn't exist when true.
    1339             : 
    1340             :      @return UNO wrapper object.
    1341             :     */
    1342             :     static UnoWrapperBase*      GetUnoWrapper( bool bCreateIfNotExists = true );
    1343             : 
    1344             :     /** Sets the application's UNO Wrapper object.
    1345             : 
    1346             :      @param     pWrapper        Pointer to UNO wrapper object.
    1347             :     */
    1348             :     static void                 SetUnoWrapper( UnoWrapperBase* pWrapper );
    1349             : 
    1350             :     ///@}
    1351             : 
    1352             : 
    1353             :     /*** @name Graphic Filters
    1354             :     */
    1355             :     ///@{
    1356             : 
    1357             :     /** Setup a new graphics filter
    1358             : 
    1359             :      @param     rLink           Const reference to a Link object, which the filter calls upon.
    1360             : 
    1361             :      @see GetFilterHdl
    1362             :     */
    1363             :     static void                 SetFilterHdl( const Link<>& rLink );
    1364             : 
    1365             :     /*** Get a new graphics filter
    1366             : 
    1367             :      @return Const reference to the Link object (the filter)
    1368             :     */
    1369             :     static const Link<>&        GetFilterHdl();
    1370             : 
    1371             :     ///@}
    1372             : 
    1373             :     /** @name Headless Mode
    1374             :     */
    1375             : 
    1376             :     /** Enables headless mode.
    1377             : 
    1378             :      @param dialogsAreFatal     Set to true if a dialog ends the session, false if not.
    1379             :     */
    1380             :     static void                 EnableHeadlessMode( bool dialogsAreFatal );
    1381             : 
    1382             :     /** Determines if headless mode is enabled
    1383             : 
    1384             :      @return True if headless mode is enabled, false if not.
    1385             :     */
    1386             :     static bool                 IsHeadlessModeEnabled();
    1387             : 
    1388             :     /** Enable Console Only mode
    1389             : 
    1390             :      Used to disable Mac specific app init that requires an app bundle.
    1391             :     */
    1392             :     static void                 EnableConsoleOnly();
    1393             : 
    1394             :     /** Determines if console only mode is enabled.
    1395             : 
    1396             :      Used to see if Mac specific app init has been disabled.
    1397             : 
    1398             :      @returns True if console only mode is on, false if not.
    1399             : 
    1400             :      @see EnableConsoleOnly
    1401             :     */
    1402             :     static bool                 IsConsoleOnly();
    1403             : 
    1404             :     ///@}
    1405             : 
    1406             :     /** @name IME Status Window Control
    1407             :     */
    1408             :     ///@{
    1409             : 
    1410             :     /** Determine application can toggle the IME status window on and off.
    1411             : 
    1412             :       @attention Must only be called with the Solar mutex locked.
    1413             : 
    1414             :       @return true if any IME status window can be toggled on and off
    1415             :             externally.
    1416             : 
    1417             :       @see ShowImeStatusWindow, GetShowImeStatusWindowDefault,
    1418             :            GetShowImeStatusWindowDefault
    1419             :      */
    1420             :     static bool                 CanToggleImeStatusWindow();
    1421             : 
    1422             :     /** Toggle any IME status window on and off.
    1423             : 
    1424             :      This only works if CanToggleImeStatusWindow returns true (otherwise,
    1425             :      any calls of this method are ignored).
    1426             : 
    1427             :      @remark Can be called without the Solar mutex locked.
    1428             : 
    1429             :      @param      bShow       If true, then show the IME status window
    1430             : 
    1431             :      @see GetShowImeStatusWindowDefault, CanToggleImeStatusWindow,
    1432             :           GetShowImeStatusWindow
    1433             :     */
    1434             :     static void                 ShowImeStatusWindow(bool bShow);
    1435             : 
    1436             :     /** Determines if the IME status window should be turned of by default.
    1437             : 
    1438             :       @return true if any IME status window should be turned on by default
    1439             :       (this decision can be locale dependent, for example).
    1440             : 
    1441             :       @see ShowImeStatusWindow, GetShowImeStatusWindowDefault,
    1442             :            CanToggleImeStatusWindow
    1443             :      */
    1444             :     static bool                 GetShowImeStatusWindowDefault();
    1445             : 
    1446             :     ///@}
    1447             : 
    1448             :     /** Get the desktop environment the process is currently running in
    1449             : 
    1450             :      @returns String representing the desktop environment
    1451             :     */
    1452             :     static const OUString&      GetDesktopEnvironment();
    1453             : 
    1454             :     /*** @name Platform Functionality
    1455             :     */
    1456             :     ///@{
    1457             : 
    1458             :     /** Add a file to the system shells recent document list if there is any.
    1459             :      This function may have no effect under Unix because there is no standard
    1460             :      API among the different desktop managers.
    1461             : 
    1462             :      @param     rFileUrl        The file url of the document.
    1463             : 
    1464             :      @param     rMimeType       The mime content type of the document specified by aFileUrl.
    1465             :                                 If an empty string will be provided "application/octet-stream"
    1466             :                                 will be used.
    1467             :     */
    1468             :     static void                 AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService);
    1469             : 
    1470             :     /*** Show a native error messagebox
    1471             : 
    1472             :      @param     sTitle          Title of error messagebox
    1473             : 
    1474             :      @param     sMessage        Message displayed in messagebox
    1475             :     */
    1476             :     static void                 ShowNativeErrorBox(const OUString& sTitle  ,
    1477             :                                                    const OUString& sMessage);
    1478             : 
    1479             :     /** Do we have a native / system file selector available?
    1480             : 
    1481             :      @returns True if native file selector is available, false otherwise.
    1482             :      */
    1483             :     static bool                 hasNativeFileSelection();
    1484             : 
    1485             :     /** Create a platform specific file picker, if one is available, otherwise return an
    1486             :      empty reference.
    1487             : 
    1488             :      @param    rServiceManager Const reference to a UNO component context (service manager).
    1489             : 
    1490             :      @returns File picker if available, otherwise an empty reference.
    1491             :     */
    1492             :     static css::uno::Reference< css::ui::dialogs::XFilePicker2 >
    1493             :         createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& rServiceManager );
    1494             : 
    1495             :     /** Create a platform specific folder picker, if one is available, otherwise return an
    1496             :      empty reference
    1497             : 
    1498             :      @param    rServiceManager Const reference to a UNO component context (service manager).
    1499             : 
    1500             :      @returns Folder picker if available, otherwise an empty reference.
    1501             :     */
    1502             :     static css::uno::Reference< css::ui::dialogs::XFolderPicker2 >
    1503             :         createFolderPicker( const css::uno::Reference< css::uno::XComponentContext >& rServiceManager );
    1504             : 
    1505             :     ///@}
    1506             : 
    1507             :     // For vclbootstrapprotector:
    1508             :     static void setDeInitHook(Link<> const & hook);
    1509             : 
    1510             : private:
    1511             : 
    1512             :     static void InitSettings(ImplSVData* pSVData);
    1513             : 
    1514             :     DECL_STATIC_LINK( Application, PostEventHandler, void* );
    1515             : };
    1516             : 
    1517             : 
    1518             : class VCL_DLLPUBLIC SolarMutexGuard
    1519             : {
    1520             : private:
    1521             :     SolarMutexGuard( const SolarMutexGuard& ) SAL_DELETED_FUNCTION;
    1522             :     const SolarMutexGuard& operator = ( const SolarMutexGuard& ) SAL_DELETED_FUNCTION;
    1523             :     comphelper::SolarMutex& m_solarMutex;
    1524             : 
    1525             : public:
    1526             :     /** Acquires the object specified as parameter.
    1527             :      */
    1528    18072108 :     SolarMutexGuard() :
    1529    18072108 :         m_solarMutex(Application::GetSolarMutex())
    1530             :     {
    1531    18072106 :         m_solarMutex.acquire();
    1532    18072107 :     }
    1533             : 
    1534             :     /** Releases the mutex or interface. */
    1535    18072107 :     ~SolarMutexGuard()
    1536             :     {
    1537    18072107 :         m_solarMutex.release();
    1538    18072106 :     }
    1539             : };
    1540             : 
    1541             : class VCL_DLLPUBLIC SolarMutexClearableGuard SAL_FINAL
    1542             : {
    1543             :     SolarMutexClearableGuard( const SolarMutexClearableGuard& ) SAL_DELETED_FUNCTION;
    1544             :     const SolarMutexClearableGuard& operator = ( const SolarMutexClearableGuard& ) SAL_DELETED_FUNCTION;
    1545             :     bool m_bCleared;
    1546             : public:
    1547             :     /** Acquires mutex
    1548             :      */
    1549     1827688 :     SolarMutexClearableGuard()
    1550             :         : m_bCleared(false)
    1551     1827688 :         , m_solarMutex( Application::GetSolarMutex() )
    1552             :     {
    1553     1827688 :         m_solarMutex.acquire();
    1554     1827688 :     }
    1555             : 
    1556             :     /** Releases mutex. */
    1557     1827688 :     ~SolarMutexClearableGuard()
    1558             :     {
    1559     1827688 :         if( !m_bCleared )
    1560             :         {
    1561      122559 :             m_solarMutex.release();
    1562             :         }
    1563     1827688 :     }
    1564             : 
    1565             :     /** Releases mutex. */
    1566     1718810 :     void SAL_CALL clear()
    1567             :     {
    1568     1718810 :         if( !m_bCleared )
    1569             :         {
    1570     1705129 :             m_solarMutex.release();
    1571     1705129 :             m_bCleared = true;
    1572             :         }
    1573     1718810 :     }
    1574             : 
    1575             : protected:
    1576             :     comphelper::SolarMutex& m_solarMutex;
    1577             : };
    1578             : 
    1579             : class VCL_DLLPUBLIC SolarMutexResettableGuard SAL_FINAL
    1580             : {
    1581             :     SolarMutexResettableGuard( const SolarMutexResettableGuard& ) SAL_DELETED_FUNCTION;
    1582             :     const SolarMutexResettableGuard& operator = ( const SolarMutexResettableGuard& ) SAL_DELETED_FUNCTION;
    1583             :     bool m_bCleared;
    1584             : public:
    1585             :     /** Acquires mutex
    1586             :      */
    1587     1439303 :     SolarMutexResettableGuard()
    1588             :         : m_bCleared(false)
    1589     1439303 :         , m_solarMutex( Application::GetSolarMutex() )
    1590             :     {
    1591     1439303 :         m_solarMutex.acquire();
    1592     1439303 :     }
    1593             : 
    1594             :     /** Releases mutex. */
    1595     1439303 :     ~SolarMutexResettableGuard()
    1596             :     {
    1597     1439303 :         if( !m_bCleared )
    1598             :         {
    1599     1167360 :             m_solarMutex.release();
    1600             :         }
    1601     1439303 :     }
    1602             : 
    1603             :     /** Releases mutex. */
    1604      554557 :     void SAL_CALL clear()
    1605             :     {
    1606      554557 :         if( !m_bCleared)
    1607             :         {
    1608      554557 :             m_solarMutex.release();
    1609      554557 :             m_bCleared = true;
    1610             :         }
    1611      554557 :     }
    1612             : 
    1613             :     /** Releases mutex. */
    1614      282614 :     void SAL_CALL reset()
    1615             :     {
    1616      282614 :         if( m_bCleared)
    1617             :         {
    1618      282614 :             m_solarMutex.acquire();
    1619      282614 :             m_bCleared = false;
    1620             :         }
    1621      282614 :     }
    1622             : 
    1623             : protected:
    1624             :     comphelper::SolarMutex& m_solarMutex;
    1625             : };
    1626             : 
    1627             : namespace vcl
    1628             : {
    1629             : 
    1630             : /** guard class that uses tryToAcquire() and has isAcquired() to check
    1631             :  */
    1632             : class SolarMutexTryAndBuyGuard
    1633             : {
    1634             : private:
    1635             :     bool m_isAcquired;
    1636             : #ifdef DBG_UTIL
    1637             :     bool m_isChecked;
    1638             : #endif
    1639             :     comphelper::SolarMutex& m_rSolarMutex;
    1640             : 
    1641             :     SolarMutexTryAndBuyGuard(const SolarMutexTryAndBuyGuard&) SAL_DELETED_FUNCTION;
    1642             :     SolarMutexTryAndBuyGuard& operator=(const SolarMutexTryAndBuyGuard&) SAL_DELETED_FUNCTION;
    1643             : 
    1644             : public:
    1645             : 
    1646           1 :     SolarMutexTryAndBuyGuard()
    1647             :         : m_isAcquired(false)
    1648             : #ifdef DBG_UTIL
    1649             :         , m_isChecked(false)
    1650             : #endif
    1651           1 :         , m_rSolarMutex(Application::GetSolarMutex())
    1652             : 
    1653             :     {
    1654           1 :         m_isAcquired = m_rSolarMutex.tryToAcquire();
    1655           1 :     }
    1656             : 
    1657           1 :     ~SolarMutexTryAndBuyGuard()
    1658             :     {
    1659             : #ifdef DBG_UTIL
    1660             :         assert(m_isChecked);
    1661             : #endif
    1662           1 :         if (m_isAcquired)
    1663           1 :             m_rSolarMutex.release();
    1664           1 :     }
    1665             : 
    1666           1 :     bool isAcquired()
    1667             :     {
    1668             : #ifdef DBG_UTIL
    1669             :         m_isChecked = true;
    1670             : #endif
    1671           1 :         return m_isAcquired;
    1672             :     }
    1673             : };
    1674             : 
    1675             : } // namespace vcl
    1676             : 
    1677             : /**
    1678             :  A helper class that calls Application::ReleaseSolarMutex() in its constructor
    1679             :  and restores the mutex in its destructor.
    1680             : */
    1681             : class SolarMutexReleaser
    1682             : {
    1683             :     sal_uLong mnReleased;
    1684             : 
    1685             : public:
    1686        1246 :     SolarMutexReleaser(): mnReleased(Application::ReleaseSolarMutex()) {}
    1687             : 
    1688        1246 :     ~SolarMutexReleaser()
    1689             :     {
    1690        1246 :         Application::AcquireSolarMutex( mnReleased );
    1691        1246 :     }
    1692             : };
    1693             : 
    1694             : VCL_DLLPUBLIC Application* GetpApp();
    1695             : 
    1696             : VCL_DLLPUBLIC bool InitVCL();
    1697             : VCL_DLLPUBLIC void DeInitVCL();
    1698             : 
    1699             : VCL_DLLPUBLIC bool InitAccessBridge();
    1700             : 
    1701             : // only allowed to call, if no thread is running. You must call JoinMainLoopThread to free all memory.
    1702             : VCL_DLLPUBLIC void CreateMainLoopThread( oslWorkerFunction pWorker, void * pThreadData );
    1703             : VCL_DLLPUBLIC void JoinMainLoopThread();
    1704             : 
    1705         151 : inline void Application::EndYield()
    1706             : {
    1707         151 :     PostUserEvent( Link<>() );
    1708         151 : }
    1709             : 
    1710             : namespace vcl
    1711             : {
    1712             : 
    1713             : VCL_DLLPUBLIC bool IsWindowSystemAvailable();
    1714             : 
    1715             : }
    1716             : 
    1717             : #endif // _APP_HXX
    1718             : 
    1719             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11