LCOV - code coverage report
Current view: top level - desktop/source/app - officeipcthread.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 6 6 100.0 %
Date: 2014-11-03 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         192 : struct ProcessDocumentsRequest
      47             : {
      48         192 :     ProcessDocumentsRequest(boost::optional< OUString > const & cwdUrl):
      49         192 :         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             :     static const char *sc_aTerminationSequence;
      91             :     static const int sc_nTSeqLength;
      92             :     static const char *sc_aShowSequence;
      93             :     static const int sc_nShSeqLength;
      94             :     static const char *sc_aConfirmationSequence;
      95             :     static const int sc_nCSeqLength;
      96             :     static const char *sc_aSendArgumentsSequence;
      97             :     static const int sc_nCSASeqLength;
      98             : 
      99             :     OfficeIPCThread();
     100             : 
     101             :     virtual ~OfficeIPCThread();
     102             : 
     103             :     /// Working method which should be overridden
     104             :     virtual void execute() SAL_OVERRIDE;
     105             : 
     106             :   public:
     107             :     enum Status
     108             :     {
     109             :         IPC_STATUS_OK,
     110             :         IPC_STATUS_2ND_OFFICE,
     111             :         IPC_STATUS_PIPE_ERROR,
     112             :         IPC_STATUS_BOOTSTRAP_ERROR
     113             :     };
     114             : 
     115             :     // controlling pipe communication during shutdown
     116             :     static void                 SetDowning();
     117             :     static void                 EnableRequests( bool i_bEnable = true );
     118             :     static bool                 AreRequestsPending();
     119             :     static void                 RequestsCompleted( int n = 1 );
     120             :     static bool                 ExecuteCmdLineRequests( ProcessDocumentsRequest& );
     121             : 
     122             :     // return sal_False if second office
     123             :     static Status               EnableOfficeIPCThread();
     124             :     static void                 DisableOfficeIPCThread(bool join = true);
     125             :     // start dispatching events...
     126             :     static void                 SetReady(
     127             :         rtl::Reference< OfficeIPCThread > const & pThread =
     128             :             rtl::Reference< OfficeIPCThread >());
     129             : 
     130          96 :     bool                        AreRequestsEnabled() const { return mbRequestsEnabled && ! mbDowning; }
     131             : };
     132             : 
     133             : 
     134             : class OfficeIPCThreadController : public ::cppu::WeakImplHelper2<
     135             :                                             ::com::sun::star::lang::XServiceInfo,
     136             :                                             ::com::sun::star::frame::XTerminateListener >
     137             : {
     138             :     public:
     139          96 :         OfficeIPCThreadController() {}
     140         192 :         virtual ~OfficeIPCThreadController() {}
     141             : 
     142             :         // XServiceInfo
     143             :         virtual OUString SAL_CALL getImplementationName()
     144             :             throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     145             :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     146             :             throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     147             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
     148             :             throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     149             : 
     150             :         // XEventListener
     151             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
     152             :             throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     153             : 
     154             :         // XTerminateListener
     155             :         virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
     156             :             throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     157             :         virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
     158             :             throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     159             : };
     160             : 
     161             : }
     162             : 
     163             : #endif // INCLUDED_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10