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

Generated by: LCOV version 1.10