LCOV - code coverage report
Current view: top level - desktop/source/app - officeipcthread.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 6 100.0 %
Date: 2015-06-13 12:38:46 Functions: 6 6 100.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_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
      21             : #define INCLUDED_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : 
      25             : #include <vector>
      26             : 
      27             : #include <com/sun/star/lang/XServiceInfo.hpp>
      28             : #include <com/sun/star/frame/XTerminateListener.hpp>
      29             : #include <osl/pipe.hxx>
      30             : #include <osl/security.hxx>
      31             : #include <osl/signal.h>
      32             : #include <rtl/ref.hxx>
      33             : #include <rtl/ustring.hxx>
      34             : #include <cppuhelper/implbase2.hxx>
      35             : #include <osl/conditn.hxx>
      36             : #include <salhelper/thread.hxx>
      37             : #include <boost/optional.hpp>
      38             : 
      39             : namespace desktop
      40             : {
      41             : 
      42             : oslSignalAction SAL_CALL SalMainPipeExchangeSignal_impl(void* /*pData*/, oslSignalInfo* pInfo);
      43             : 
      44             : // A request for the current office
      45             : // that was given by command line or by IPC pipe communication.
      46         128 : struct ProcessDocumentsRequest
      47             : {
      48         128 :     ProcessDocumentsRequest(boost::optional< OUString > const & cwdUrl):
      49         128 :         aCwdUrl(cwdUrl), pcProcessed( NULL ), bTextCat( false ) {}
      50             : 
      51             :     boost::optional< OUString > aCwdUrl;
      52             :     OUString aModule;
      53             :     std::vector< OUString > aOpenList; // Documents that should be opened in the default way
      54             :     std::vector< OUString > aViewList; // Documents that should be opened in viewmode
      55             :     std::vector< OUString > aStartList; // Documents/Presentations that should be started
      56             :     std::vector< OUString > aPrintList; // Documents that should be printed on default printer
      57             :     std::vector< OUString > aForceOpenList; // Documents that should be forced to open for editing (even templates)
      58             :     std::vector< OUString > aForceNewList; // Documents that should be forced to create a new document
      59             :     OUString aPrinterName;   // The printer name that should be used for printing
      60             :     std::vector< OUString > aPrintToList; // Documents that should be printed on the given printer
      61             :     std::vector< OUString > aConversionList;
      62             :     OUString aConversionParams;
      63             :     OUString aConversionOut;
      64             :     std::vector< OUString > aInFilter;
      65             :     ::osl::Condition *pcProcessed;  // pointer condition to be set when the request has been processed
      66             :     bool bTextCat; // boolean flag indicating whether to dump text content to screen
      67             : };
      68             : 
      69             : class DispatchWatcher;
      70             : class OfficeIPCThread : public salhelper::Thread
      71             : {
      72             :   private:
      73             :     static rtl::Reference< OfficeIPCThread > pGlobalOfficeIPCThread;
      74             : 
      75             :     osl::Pipe                   maPipe;
      76             :     bool                        mbDowning;
      77             :     bool                        mbRequestsEnabled;
      78             :     int                         mnPendingRequests;
      79             :     DispatchWatcher*            mpDispatchWatcher;
      80             : 
      81             :     /* condition to be set when the request has been processed */
      82             :     ::osl::Condition cProcessed;
      83             : 
      84             :     /* condition to be set when the main event loop is ready
      85             :        otherwise an error dialogs event loop could eat away
      86             :        requests from a 2nd office */
      87             :     ::osl::Condition cReady;
      88             : 
      89             :     static ::osl::Mutex&        GetMutex();
      90             : 
      91             :     OfficeIPCThread();
      92             : 
      93             :     virtual ~OfficeIPCThread();
      94             : 
      95             :     /// Working method which should be overridden
      96             :     virtual void execute() SAL_OVERRIDE;
      97             : 
      98             :   public:
      99             :     enum Status
     100             :     {
     101             :         IPC_STATUS_OK,
     102             :         IPC_STATUS_2ND_OFFICE,
     103             :         IPC_STATUS_PIPE_ERROR,
     104             :         IPC_STATUS_BOOTSTRAP_ERROR
     105             :     };
     106             : 
     107             :     // controlling pipe communication during shutdown
     108             :     static void                 SetDowning();
     109             :     static void                 EnableRequests( bool i_bEnable = true );
     110             :     static bool                 AreRequestsPending();
     111             :     static void                 RequestsCompleted( int n = 1 );
     112             :     static bool                 ExecuteCmdLineRequests( ProcessDocumentsRequest& );
     113             : 
     114             :     // return sal_False if second office
     115             :     static Status               EnableOfficeIPCThread();
     116             :     static void                 DisableOfficeIPCThread(bool join = true);
     117             :     // start dispatching events...
     118             :     static void                 SetReady(
     119             :         rtl::Reference< OfficeIPCThread > const & pThread =
     120             :             rtl::Reference< OfficeIPCThread >());
     121             :     static void                 WaitForReady(
     122             :         rtl::Reference< OfficeIPCThread > const & pThread =
     123             :             rtl::Reference< OfficeIPCThread >());
     124             :     static bool                 IsEnabled();
     125             : 
     126          65 :     bool                        AreRequestsEnabled() const { return mbRequestsEnabled && ! mbDowning; }
     127             : };
     128             : 
     129             : 
     130             : class OfficeIPCThreadController : public ::cppu::WeakImplHelper2<
     131             :                                             ::com::sun::star::lang::XServiceInfo,
     132             :                                             ::com::sun::star::frame::XTerminateListener >
     133             : {
     134             :     public:
     135          64 :         OfficeIPCThreadController() {}
     136         128 :         virtual ~OfficeIPCThreadController() {}
     137             : 
     138             :         // XServiceInfo
     139             :         virtual OUString SAL_CALL getImplementationName()
     140             :             throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     141             :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     142             :             throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     143             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
     144             :             throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     145             : 
     146             :         // XEventListener
     147             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
     148             :             throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     149             : 
     150             :         // XTerminateListener
     151             :         virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
     152             :             throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     153             :         virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
     154             :             throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     155             : };
     156             : 
     157             : }
     158             : 
     159             : #endif // INCLUDED_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
     160             : 
     161             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11