LCOV - code coverage report
Current view: top level - vcl/inc/vcl - svapp.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 28 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 14 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SV_SVAPP_HXX
      30                 :            : #define _SV_SVAPP_HXX
      31                 :            : 
      32                 :            : #include <sal/config.h>
      33                 :            : 
      34                 :            : #include <stdexcept>
      35                 :            : 
      36                 :            : #include <osl/thread.hxx>
      37                 :            : #include <osl/mutex.hxx>
      38                 :            : #include <tools/string.hxx>
      39                 :            : #include <tools/link.hxx>
      40                 :            : #include <tools/solar.h>
      41                 :            : #include <vcl/dllapi.h>
      42                 :            : #include <vcl/apptypes.hxx>
      43                 :            : #include <vcl/settings.hxx>
      44                 :            : #include <vcl/vclevent.hxx>
      45                 :            : #include <vcl/rendergraphicrasterizer.hxx>
      46                 :            : class BitmapEx;
      47                 :            : class Link;
      48                 :            : class AllSettings;
      49                 :            : class DataChangedEvent;
      50                 :            : class Accelerator;
      51                 :            : class Help;
      52                 :            : class OutputDevice;
      53                 :            : class Window;
      54                 :            : class WorkWindow;
      55                 :            : class MenuBar;
      56                 :            : class UnoWrapperBase;
      57                 :            : class Reflection;
      58                 :            : class KeyCode;
      59                 :            : class NotifyEvent;
      60                 :            : class KeyEvent;
      61                 :            : class MouseEvent;
      62                 :            : 
      63                 :            : #include <com/sun/star/uno/Reference.h>
      64                 :            : #include <com/sun/star/connection/XConnection.hpp>
      65                 :            : 
      66                 :            : namespace com {
      67                 :            : namespace sun {
      68                 :            : namespace star {
      69                 :            : namespace uno {
      70                 :            :     class XComponentContext;
      71                 :            : }
      72                 :            : namespace ui {
      73                 :            :     namespace dialogs {
      74                 :            :         class XFilePicker2;
      75                 :            :         class XFolderPicker;
      76                 :            :     }
      77                 :            : }
      78                 :            : namespace awt {
      79                 :            :     class XToolkit;
      80                 :            :     class XDisplayConnection;
      81                 :            : }
      82                 :            : } } }
      83                 :            : 
      84                 :            : // helper needed by SalLayout implementations as well as svx/source/dialog/svxbmpnumbalueset.cxx
      85                 :            : VCL_DLLPUBLIC sal_UCS4 GetMirroredChar( sal_UCS4 );
      86                 :            : 
      87                 :            : // --------------------
      88                 :            : // - SystemWindowMode -
      89                 :            : // --------------------
      90                 :            : 
      91                 :            : #define SYSTEMWINDOW_MODE_NOAUTOMODE    ((sal_uInt16)0x0001)
      92                 :            : #define SYSTEMWINDOW_MODE_DIALOG        ((sal_uInt16)0x0002)
      93                 :            : 
      94                 :            : // -------------
      95                 :            : // - EventHook -
      96                 :            : // -------------
      97                 :            : 
      98                 :            : typedef long (*VCLEventHookProc)( NotifyEvent& rEvt, void* pData );
      99                 :            : 
     100                 :            : // --------------------
     101                 :            : // - ApplicationEvent -
     102                 :            : // --------------------
     103                 :            : 
     104                 :            : // Build in again, in order to make AppEvents work on MACs
     105                 :            : 
     106                 :            : // ATTENTION: ENUM duplicate in daemon.cxx under Unix!
     107                 :            : 
     108                 :            : #ifdef UNX
     109                 :            : enum Service { SERVICE_OLE, SERVICE_APPEVENT, SERVICE_IPC };
     110                 :            : #endif
     111                 :            : 
     112                 :            : class VCL_DLLPUBLIC ApplicationEvent
     113                 :            : {
     114                 :            : public:
     115                 :            :     enum Type {
     116                 :            :         TYPE_ACCEPT, TYPE_APPEAR, TYPE_HELP, TYPE_OPEN, TYPE_OPENHELPURL,
     117                 :            :         TYPE_PRINT, TYPE_PRIVATE_DOSHUTDOWN, TYPE_QUICKSTART, TYPE_SHOWDIALOG,
     118                 :            :         TYPE_UNACCEPT
     119                 :            :     };
     120                 :            : 
     121                 :            :     ApplicationEvent() {}
     122                 :            : 
     123                 :            :     explicit ApplicationEvent(
     124                 :            :         Type rEvent, const rtl::OUString& rData = rtl::OUString()):
     125                 :            :         aEvent(rEvent),
     126                 :            :         aData(rData)
     127                 :            :     {}
     128                 :            : 
     129                 :            :     Type GetEvent() const { return aEvent; }
     130                 :            :     const rtl::OUString& GetData() const { return aData; }
     131                 :            : 
     132                 :            : private:
     133                 :            :     Type aEvent;
     134                 :            :     rtl::OUString aData;
     135                 :            : };
     136                 :            : 
     137                 :            : class VCL_DLLPUBLIC PropertyHandler
     138                 :            : {
     139                 :            : public:
     140                 :            :     virtual void                Property( ApplicationProperty& ) = 0;
     141                 :            : 
     142                 :            : protected:
     143                 :            :     ~PropertyHandler() {}
     144                 :            : };
     145                 :            : 
     146                 :            : // ---------------
     147                 :            : // - Application -
     148                 :            : // ---------------
     149                 :            : 
     150                 :            : class VCL_DLLPUBLIC Application
     151                 :            : {
     152                 :            : public:
     153                 :            :     enum DialogCancelMode {
     154                 :            :         DIALOG_CANCEL_OFF, ///< do not automatically cancel dialogs
     155                 :            :         DIALOG_CANCEL_SILENT, ///< silently cancel any dialogs
     156                 :            :         DIALOG_CANCEL_FATAL
     157                 :            :             ///< cancel any dialogs by throwing a DialogCancelledException
     158                 :            :     };
     159                 :            : 
     160                 :            :     class VCL_DLLPUBLIC DialogCancelledException:
     161                 :            :         virtual public std::runtime_error
     162                 :            :     {
     163                 :            :     public:
     164                 :          0 :         explicit DialogCancelledException(char const * what_arg):
     165 [ #  # ][ #  # ]:          0 :             runtime_error(what_arg) {}
     166                 :            : 
     167                 :            :         virtual ~DialogCancelledException() throw ();
     168                 :            :     };
     169                 :            : 
     170                 :            :                                 Application();
     171                 :            :     virtual                     ~Application();
     172                 :            : 
     173                 :            :     virtual int                 Main() = 0;
     174                 :            : 
     175                 :            :     virtual sal_Bool                QueryExit();
     176                 :            : 
     177                 :            :     virtual void                UserEvent( sal_uLong nEvent, void* pEventData );
     178                 :            : 
     179                 :            :     virtual void                ActivateExtHelp();
     180                 :            :     virtual void                DeactivateExtHelp();
     181                 :            : 
     182                 :            :     virtual void                FocusChanged();
     183                 :            :     virtual void                DataChanged( const DataChangedEvent& rDCEvt );
     184                 :            : 
     185                 :            :     virtual void                Init();
     186                 :            :     virtual void                InitFinished();
     187                 :            :     virtual void                DeInit();
     188                 :            : 
     189                 :            :     static sal_uInt16               GetCommandLineParamCount();
     190                 :            :     static XubString            GetCommandLineParam( sal_uInt16 nParam );
     191                 :            :     static const XubString&     GetAppFileName();
     192                 :            : 
     193                 :            :     virtual sal_uInt16              Exception( sal_uInt16 nError );
     194                 :            :     static void                 Abort( const XubString& rErrorText );
     195                 :            : 
     196                 :            :     static void                 Execute();
     197                 :            :     static void                 Quit();
     198                 :            :     static void                 Reschedule( bool bAllEvents = false );
     199                 :            :     static void                 Yield( bool bAllEvents = false );
     200                 :            :     static void                 EndYield();
     201                 :            :     static osl::SolarMutex&     GetSolarMutex();
     202                 :            :     static oslThreadIdentifier  GetMainThreadIdentifier();
     203                 :            :     static sal_uLong                ReleaseSolarMutex();
     204                 :            :     static void                 AcquireSolarMutex( sal_uLong nCount );
     205                 :            :     static void                 EnableNoYieldMode( bool i_bNoYield );
     206                 :            :     static void                 AddPostYieldListener( const Link& i_rListener );
     207                 :            :     static void                 RemovePostYieldListener( const Link& i_rListener );
     208                 :            : 
     209                 :            :     static sal_Bool                 IsInMain();
     210                 :            :     static sal_Bool                 IsInExecute();
     211                 :            :     static sal_Bool                 IsInModalMode();
     212                 :            : 
     213                 :            :     static sal_uInt16               GetDispatchLevel();
     214                 :            :     static sal_Bool                 AnyInput( sal_uInt16 nType = VCL_INPUT_ANY );
     215                 :            :     static sal_uLong                GetLastInputInterval();
     216                 :            :     static sal_Bool                 IsUICaptured();
     217                 :            : 
     218                 :            :     virtual void                SystemSettingsChanging( AllSettings& rSettings,
     219                 :            :                                                         Window* pFrame );
     220                 :            :     static void                 MergeSystemSettings( AllSettings& rSettings );
     221                 :            :     /** validate that the currently selected system UI font is suitable
     222                 :            :         to display the application's UI.
     223                 :            : 
     224                 :            :         A localized test string will be checked if it can be displayed
     225                 :            :         in the currently selected system UI font. If no glyphs are
     226                 :            :         missing it can be assumed that the font is proper for display
     227                 :            :         of the application's UI.
     228                 :            : 
     229                 :            :         @returns
     230                 :            :         <TRUE/> if the system font is suitable for our UI
     231                 :            :         <FALSE/> if the test string could not be displayed with the system font
     232                 :            :      */
     233                 :            :     static bool                 ValidateSystemFont();
     234                 :            : 
     235                 :            :     static void                 SetSettings( const AllSettings& rSettings );
     236                 :            :     static const AllSettings&   GetSettings();
     237                 :            :     static void                 NotifyAllWindows( DataChangedEvent& rDCEvt );
     238                 :            : 
     239                 :            :     static void                 AddEventListener( const Link& rEventListener );
     240                 :            :     static void                 RemoveEventListener( const Link& rEventListener );
     241                 :            :     static void                 AddKeyListener( const Link& rKeyListener );
     242                 :            :     static void                 RemoveKeyListener( const Link& rKeyListener );
     243                 :            :     static void                 ImplCallEventListeners( sal_uLong nEvent, Window* pWin, void* pData );
     244                 :            :     static void                 ImplCallEventListeners( VclSimpleEvent* pEvent );
     245                 :            :     static sal_Bool                 HandleKey( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent );
     246                 :            : 
     247                 :            :     static sal_uLong                PostKeyEvent( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent );
     248                 :            :     static sal_uLong                PostMouseEvent( sal_uLong nEvent, Window *pWin, MouseEvent* pMouseEvent );
     249                 :            :     static void                 RemoveMouseAndKeyEvents( Window *pWin );
     250                 :            : 
     251                 :            :     static sal_uLong                PostUserEvent( const Link& rLink, void* pCaller = NULL );
     252                 :            :     static sal_Bool                 PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller = NULL );
     253                 :            :     static void                 RemoveUserEvent( sal_uLong nUserEvent );
     254                 :            : 
     255                 :            :     static sal_Bool                 InsertIdleHdl( const Link& rLink, sal_uInt16 nPriority );
     256                 :            :     static void                 RemoveIdleHdl( const Link& rLink );
     257                 :            : 
     258                 :            :     virtual void                AppEvent( const ApplicationEvent& rAppEvent );
     259                 :            : 
     260                 :            :     virtual void                Property( ApplicationProperty& );
     261                 :            : 
     262                 :            : #ifndef NO_GETAPPWINDOW
     263                 :            :     static WorkWindow*          GetAppWindow();
     264                 :            : #endif
     265                 :            : 
     266                 :            :     static Window*              GetFocusWindow();
     267                 :            :     static OutputDevice*        GetDefaultDevice();
     268                 :            : 
     269                 :            :     static Window*              GetFirstTopLevelWindow();
     270                 :            :     static Window*              GetNextTopLevelWindow( Window* pWindow );
     271                 :            : 
     272                 :            :     static long                 GetTopWindowCount();
     273                 :            :     static Window*              GetTopWindow( long nIndex );
     274                 :            :     static Window*              GetActiveTopWindow();
     275                 :            : 
     276                 :            :     static void                 SetAppName( const String& rUniqueName );
     277                 :            :     static String               GetAppName();
     278                 :            :     static bool                 LoadBrandBitmap (const char* pName, BitmapEx &rBitmap);
     279                 :            :     static vcl::RenderGraphicRasterizer  LoadBrandSVG (const char* pName);
     280                 :            : 
     281                 :            :     // default name of the application for message dialogs and printing
     282                 :            :     static void                 SetDisplayName( const UniString& rDisplayName );
     283                 :            :     static UniString            GetDisplayName();
     284                 :            : 
     285                 :            : 
     286                 :            :     static unsigned int         GetScreenCount();
     287                 :            :     static Rectangle            GetScreenPosSizePixel( unsigned int nScreen );
     288                 :            : 
     289                 :            :     // IsUnifiedDisplay returns:
     290                 :            :     //        true:  screens form up one large display area
     291                 :            :     //               windows can be moved between single screens
     292                 :            :     //               (e.g. Xserver with Xinerama, Windows)
     293                 :            :     //        false: different screens are separate and windows cannot be moved
     294                 :            :     //               between them (e.g. Xserver with multiple screens)
     295                 :            :     SAL_DLLPRIVATE static bool          IsUnifiedDisplay();
     296                 :            :     // if IsUnifiedDisplay() == true the return value will be
     297                 :            :     // nearest screen of the target rectangle
     298                 :            :     // in case of IsUnifiedDisplay() == false the return value
     299                 :            :     // will always be GetDisplayDefaultScreen()
     300                 :            :     SAL_DLLPRIVATE static unsigned int  GetBestScreen( const Rectangle& );
     301                 :            :     SAL_DLLPRIVATE static Rectangle     GetWorkAreaPosSizePixel( unsigned int nScreen );
     302                 :            :     // This returns the LCD screen number for a laptop, or the primary
     303                 :            :     // external VGA display for a desktop machine - it is where a presenter
     304                 :            :     // console should be rendered if there are other (non-built-in) screens
     305                 :            :     // present.
     306                 :            :     SAL_DLLPRIVATE static unsigned int  GetDisplayBuiltInScreen();
     307                 :            :     SAL_DLLPRIVATE static rtl::OUString GetDisplayScreenName( unsigned int nScreen );
     308                 :            : 
     309                 :            :     static const LocaleDataWrapper& GetAppLocaleDataWrapper();
     310                 :            : 
     311                 :            :     static sal_Bool                 InsertAccel( Accelerator* pAccel );
     312                 :            :     static void                 RemoveAccel( Accelerator* pAccel );
     313                 :            : 
     314                 :            :     static long                 CallEventHooks( NotifyEvent& rEvt );
     315                 :            : 
     316                 :            :     static void                 SetHelp( Help* pHelp = NULL );
     317                 :            :     static Help*                GetHelp();
     318                 :            : 
     319                 :            :     static void                 EnableAutoHelpId( sal_Bool bEnabled = sal_True );
     320                 :            :     static sal_Bool                 IsAutoHelpIdEnabled();
     321                 :            : 
     322                 :            :     static void                 EnableAutoMnemonic( sal_Bool bEnabled = sal_True );
     323                 :            :     static sal_Bool                 IsAutoMnemonicEnabled();
     324                 :            : 
     325                 :            :     static sal_uLong                GetReservedKeyCodeCount();
     326                 :            :     static const KeyCode*       GetReservedKeyCode( sal_uLong i );
     327                 :            : 
     328                 :            :     static void                 SetDefDialogParent( Window* pWindow );
     329                 :            :     static Window*              GetDefDialogParent();
     330                 :            : 
     331                 :            :     static DialogCancelMode GetDialogCancelMode();
     332                 :            :     static void SetDialogCancelMode( DialogCancelMode mode );
     333                 :            :     static sal_Bool                 IsDialogCancelEnabled();
     334                 :            : 
     335                 :            :     static void                 SetSystemWindowMode( sal_uInt16 nMode );
     336                 :            :     static sal_uInt16               GetSystemWindowMode();
     337                 :            : 
     338                 :            :     static void                 SetDialogScaleX( short nScale );
     339                 :            : 
     340                 :            :     static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayConnection > GetDisplayConnection();
     341                 :            : 
     342                 :            :     // The global service manager has to be created before!
     343                 :            :     static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > GetVCLToolkit();
     344                 :            :     static UnoWrapperBase*      GetUnoWrapper( sal_Bool bCreateIfNotExists = sal_True );
     345                 :            :     static void                 SetUnoWrapper( UnoWrapperBase* pWrapper );
     346                 :            : 
     347                 :            :     static void                 SetFilterHdl( const Link& rLink );
     348                 :            :     static const Link&          GetFilterHdl();
     349                 :            : 
     350                 :            :     static void                 EnableHeadlessMode( bool dialogsAreFatal );
     351                 :            :     static sal_Bool                 IsHeadlessModeEnabled();
     352                 :            : 
     353                 :            :     static bool IsHeadlessModeRequested();
     354                 :            :         ///< check command line arguments for --headless
     355                 :            : 
     356                 :            :     static void                 ShowNativeErrorBox(const String& sTitle  ,
     357                 :            :                                                    const String& sMessage);
     358                 :            : 
     359                 :            :     // IME Status Window Control:
     360                 :            : 
     361                 :            :     /** Return true if any IME status window can be toggled on and off
     362                 :            :         externally.
     363                 :            : 
     364                 :            :         Must only be called with the Solar mutex locked.
     365                 :            :      */
     366                 :            :     static bool CanToggleImeStatusWindow();
     367                 :            : 
     368                 :            :     /** Toggle any IME status window on and off.
     369                 :            : 
     370                 :            :         This only works if CanToggleImeStatusWinodw returns true (otherwise,
     371                 :            :         any calls of this method are ignored).
     372                 :            : 
     373                 :            :         Must only be called with the Solar mutex locked.
     374                 :            :      */
     375                 :            :     static void ShowImeStatusWindow(bool bShow);
     376                 :            : 
     377                 :            :     /** Return true if any IME status window should be turned on by default
     378                 :            :         (this decision can be locale dependent, for example).
     379                 :            : 
     380                 :            :         Can be called without the Solar mutex locked.
     381                 :            :      */
     382                 :            :     static bool GetShowImeStatusWindowDefault();
     383                 :            : 
     384                 :            :     /** Returns a string representing the desktop environment
     385                 :            :         the process is currently running in.
     386                 :            :      */
     387                 :            :     static const ::rtl::OUString& GetDesktopEnvironment();
     388                 :            : 
     389                 :            :     /** Add a file to the system shells recent document list if there is any.
     390                 :            :           This function may have no effect under Unix because there is no
     391                 :            :           standard API among the different desktop managers.
     392                 :            : 
     393                 :            :           @param rFileUrl
     394                 :            :                     The file url of the document.
     395                 :            : 
     396                 :            :           @param rMimeType
     397                 :            :           The mime content type of the document specified by aFileUrl.
     398                 :            :           If an empty string will be provided "application/octet-stream"
     399                 :            :           will be used.
     400                 :            :     */
     401                 :            :     static void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType);
     402                 :            : 
     403                 :            :     /** Do we have a native / system file selector available ?
     404                 :            :      */
     405                 :            :     static bool hasNativeFileSelection();
     406                 :            : 
     407                 :            :     /** Create a platform specific file picker, if one is available,
     408                 :            :         otherwise return an empty reference
     409                 :            :     */
     410                 :            :     static com::sun::star::uno::Reference< com::sun::star::ui::dialogs::XFilePicker2 >
     411                 :            :         createFilePicker( const com::sun::star::uno::Reference<
     412                 :            :                               com::sun::star::uno::XComponentContext >& rServiceManager );
     413                 :            : 
     414                 :            :     /** Create a platform specific folder picker, if one is available,
     415                 :            :         otherwise return an empty reference
     416                 :            :     */
     417                 :            :     static com::sun::star::uno::Reference< com::sun::star::ui::dialogs::XFolderPicker >
     418                 :            :         createFolderPicker( const com::sun::star::uno::Reference<
     419                 :            :                               com::sun::star::uno::XComponentContext >& rServiceManager );
     420                 :            : 
     421                 :            : private:
     422                 :            : 
     423                 :            :     DECL_STATIC_LINK( Application, PostEventHandler, void* );
     424                 :            : };
     425                 :            : 
     426                 :            : 
     427                 :            : class VCL_DLLPUBLIC SolarMutexGuard
     428                 :            : {
     429                 :            :     private:
     430                 :            :         SolarMutexGuard( const SolarMutexGuard& );
     431                 :            :         const SolarMutexGuard& operator = ( const SolarMutexGuard& );
     432                 :            :         ::osl::SolarMutex& m_solarMutex;
     433                 :            : 
     434                 :            :     public:
     435                 :            : 
     436                 :            :         /** Acquires the object specified as parameter.
     437                 :            :          */
     438                 :          0 :         SolarMutexGuard() :
     439                 :          0 :         m_solarMutex(Application::GetSolarMutex())
     440                 :            :     {
     441                 :          0 :         m_solarMutex.acquire();
     442                 :          0 :     }
     443                 :            : 
     444                 :            :     /** Releases the mutex or interface. */
     445                 :          0 :     ~SolarMutexGuard()
     446                 :            :     {
     447                 :          0 :         m_solarMutex.release();
     448                 :          0 :     }
     449                 :            : };
     450                 :            : 
     451                 :            : class VCL_DLLPUBLIC SolarMutexClearableGuard
     452                 :            : {
     453                 :            :     SolarMutexClearableGuard( const SolarMutexClearableGuard& );
     454                 :            :     const SolarMutexClearableGuard& operator = ( const SolarMutexClearableGuard& );
     455                 :            :     bool m_bCleared;
     456                 :            : public:
     457                 :            :     /** Acquires mutex
     458                 :            :         @param pMutex pointer to mutex which is to be acquired  */
     459                 :          0 :     SolarMutexClearableGuard()
     460                 :            :         : m_bCleared(false)
     461                 :          0 :         , m_solarMutex( Application::GetSolarMutex() )
     462                 :            :         {
     463                 :          0 :             m_solarMutex.acquire();
     464                 :          0 :         }
     465                 :            : 
     466                 :            :     /** Releases mutex. */
     467                 :          0 :     virtual ~SolarMutexClearableGuard()
     468                 :          0 :         {
     469         [ #  # ]:          0 :             if( !m_bCleared )
     470                 :            :             {
     471                 :          0 :                 m_solarMutex.release();
     472                 :            :             }
     473         [ #  # ]:          0 :         }
     474                 :            : 
     475                 :            :     /** Releases mutex. */
     476                 :          0 :     void SAL_CALL clear()
     477                 :            :         {
     478         [ #  # ]:          0 :             if( !m_bCleared )
     479                 :            :             {
     480                 :          0 :                 m_solarMutex.release();
     481                 :          0 :                 m_bCleared = true;
     482                 :            :             }
     483                 :          0 :         }
     484                 :            : protected:
     485                 :            :     osl::SolarMutex& m_solarMutex;
     486                 :            : };
     487                 :            : 
     488                 :            : class VCL_DLLPUBLIC SolarMutexResettableGuard
     489                 :            : {
     490                 :            :     SolarMutexResettableGuard( const SolarMutexResettableGuard& );
     491                 :            :     const SolarMutexResettableGuard& operator = ( const SolarMutexResettableGuard& );
     492                 :            :     bool m_bCleared;
     493                 :            : public:
     494                 :            :     /** Acquires mutex
     495                 :            :         @param pMutex pointer to mutex which is to be acquired  */
     496                 :            :     SolarMutexResettableGuard()
     497                 :            :         : m_bCleared(false)
     498                 :            :         , m_solarMutex( Application::GetSolarMutex() )
     499                 :            :         {
     500                 :            :             m_solarMutex.acquire();
     501                 :            :         }
     502                 :            : 
     503                 :            :     /** Releases mutex. */
     504                 :          0 :     virtual ~SolarMutexResettableGuard()
     505                 :          0 :         {
     506         [ #  # ]:          0 :             if( !m_bCleared )
     507                 :            :             {
     508                 :          0 :                 m_solarMutex.release();
     509                 :            :             }
     510         [ #  # ]:          0 :         }
     511                 :            : 
     512                 :            :     /** Releases mutex. */
     513                 :            :     void SAL_CALL clear()
     514                 :            :         {
     515                 :            :             if( !m_bCleared)
     516                 :            :             {
     517                 :            :                 m_solarMutex.release();
     518                 :            :                 m_bCleared = true;
     519                 :            :             }
     520                 :            :         }
     521                 :            :     /** Releases mutex. */
     522                 :            :     void SAL_CALL reset()
     523                 :            :         {
     524                 :            :             if( m_bCleared)
     525                 :            :             {
     526                 :            :                 m_solarMutex.acquire();
     527                 :            :                 m_bCleared = false;
     528                 :            :             }
     529                 :            :         }
     530                 :            : protected:
     531                 :            :     osl::SolarMutex& m_solarMutex;
     532                 :            : };
     533                 :            : 
     534                 :            : 
     535                 :            : /**
     536                 :            :  A helper class that calls Application::ReleaseSolarMutex() in its constructor
     537                 :            :  and restores the mutex in its destructor.
     538                 :            : */
     539                 :            : class SolarMutexReleaser
     540                 :            : {
     541                 :            :     sal_uLong mnReleased;
     542                 :            : 
     543                 :            : public:
     544                 :            :     SolarMutexReleaser(): mnReleased(Application::ReleaseSolarMutex()) {}
     545                 :            : 
     546                 :            :     ~SolarMutexReleaser()
     547                 :            :     {
     548                 :            :         Application::AcquireSolarMutex( mnReleased );
     549                 :            :     }
     550                 :            : };
     551                 :            : 
     552                 :            : VCL_DLLPUBLIC Application* GetpApp();
     553                 :            : 
     554                 :            : VCL_DLLPUBLIC sal_Bool InitVCL( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & );
     555                 :            : VCL_DLLPUBLIC void DeInitVCL();
     556                 :            : 
     557                 :            : VCL_DLLPUBLIC sal_Bool InitAccessBridge( sal_Bool bAllowCancel, sal_Bool &rCancelled );
     558                 :            : 
     559                 :            : // only allowed to call, if no thread is running. You must call JoinMainLoopThread to free all memory.
     560                 :            : VCL_DLLPUBLIC void CreateMainLoopThread( oslWorkerFunction pWorker, void * pThreadData );
     561                 :            : VCL_DLLPUBLIC void JoinMainLoopThread();
     562                 :            : 
     563                 :            : inline void Application::EndYield()
     564                 :            : {
     565                 :            :     PostUserEvent( Link() );
     566                 :            : }
     567                 :            : 
     568                 :            : #endif // _APP_HXX
     569                 :            : 
     570                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10