LCOV - code coverage report
Current view: top level - libreoffice/desktop/source/app - officeipcthread.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 6 0.0 %
Date: 2012-12-27 Functions: 0 6 0.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 _DESKTOP_OFFICEIPCTHREAD_HXX_
      21             : #define _DESKTOP_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           0 : struct ProcessDocumentsRequest
      47             : {
      48           0 :     ProcessDocumentsRequest(boost::optional< rtl::OUString > const & cwdUrl):
      49           0 :         aCwdUrl(cwdUrl), pcProcessed( NULL ) {}
      50             : 
      51             :     boost::optional< ::rtl::OUString > aCwdUrl;
      52             :     ::rtl::OUString aModule;
      53             :     std::vector< rtl::OUString > aOpenList; // Documents that should be opened in the default way
      54             :     std::vector< rtl::OUString > aViewList; // Documents that should be opened in viewmode
      55             :     std::vector< rtl::OUString > aStartList; // Documents/Presentations that should be started
      56             :     std::vector< rtl::OUString > aPrintList; // Documents that should be printed on default printer
      57             :     std::vector< rtl::OUString > aForceOpenList; // Documents that should be forced to open for editing (even templates)
      58             :     std::vector< rtl::OUString > aForceNewList; // Documents that should be forced to create a new document
      59             :     ::rtl::OUString aPrinterName;   // The printer name that should be used for printing
      60             :     std::vector< rtl::OUString > aPrintToList; // Documents that should be printed on the given printer
      61             :     std::vector< rtl::OUString > aConversionList;
      62             :     ::rtl::OUString aConversionParams;
      63             :     ::rtl::OUString aConversionOut;
      64             :     std::vector< rtl::OUString > aInFilter;
      65             :     ::osl::Condition *pcProcessed;  // pointer condition to be set when the request has been processed
      66             : };
      67             : 
      68             : class DispatchWatcher;
      69             : class OfficeIPCThread : public salhelper::Thread
      70             : {
      71             :   private:
      72             :     static rtl::Reference< OfficeIPCThread > pGlobalOfficeIPCThread;
      73             : 
      74             :     osl::Pipe                   maPipe;
      75             :     bool                        mbDowning;
      76             :     bool                        mbRequestsEnabled;
      77             :     int                         mnPendingRequests;
      78             :     DispatchWatcher*            mpDispatchWatcher;
      79             : 
      80             :     /* condition to be set when the request has been processed */
      81             :     ::osl::Condition cProcessed;
      82             : 
      83             :     /* condition to be set when the main event loop is ready
      84             :        otherwise an error dialogs event loop could eat away
      85             :        requests from a 2nd office */
      86             :     ::osl::Condition cReady;
      87             : 
      88             :     static ::osl::Mutex&        GetMutex();
      89             :     static const char *sc_aTerminationSequence;
      90             :     static const int sc_nTSeqLength;
      91             :     static const char *sc_aShowSequence;
      92             :     static const int sc_nShSeqLength;
      93             :     static const char *sc_aConfirmationSequence;
      94             :     static const int sc_nCSeqLength;
      95             :     static const char *sc_aSendArgumentsSequence;
      96             :     static const int sc_nCSASeqLength;
      97             : 
      98             :     OfficeIPCThread();
      99             : 
     100             :     virtual ~OfficeIPCThread();
     101             : 
     102             :     /// Working method which should be overridden
     103             :     virtual void execute();
     104             : 
     105             :   public:
     106             :     enum Status
     107             :     {
     108             :         IPC_STATUS_OK,
     109             :         IPC_STATUS_2ND_OFFICE,
     110             :         IPC_STATUS_BOOTSTRAP_ERROR
     111             :     };
     112             : 
     113             :     // controlling pipe communication during shutdown
     114             :     static void                 SetDowning();
     115             :     static void                 EnableRequests( bool i_bEnable = true );
     116             :     static sal_Bool             AreRequestsPending();
     117             :     static void                 RequestsCompleted( int n = 1 );
     118             :     static sal_Bool             ExecuteCmdLineRequests( ProcessDocumentsRequest& );
     119             : 
     120             :     // return sal_False if second office
     121             :     static Status               EnableOfficeIPCThread();
     122             :     static void                 DisableOfficeIPCThread(bool join = true);
     123             :     // start dispatching events...
     124             :     static void                 SetReady(
     125             :         rtl::Reference< OfficeIPCThread > const & pThread =
     126             :             rtl::Reference< OfficeIPCThread >());
     127             : 
     128           0 :     bool                        AreRequestsEnabled() const { return mbRequestsEnabled && ! mbDowning; }
     129             : };
     130             : 
     131             : 
     132             : class OfficeIPCThreadController : public ::cppu::WeakImplHelper2<
     133             :                                             ::com::sun::star::lang::XServiceInfo,
     134             :                                             ::com::sun::star::frame::XTerminateListener >
     135             : {
     136             :     public:
     137           0 :         OfficeIPCThreadController() {}
     138           0 :         virtual ~OfficeIPCThreadController() {}
     139             : 
     140             :         // XServiceInfo
     141             :         virtual ::rtl::OUString SAL_CALL getImplementationName()
     142             :             throw ( ::com::sun::star::uno::RuntimeException );
     143             :         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
     144             :             throw ( ::com::sun::star::uno::RuntimeException );
     145             :         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
     146             :             throw ( ::com::sun::star::uno::RuntimeException );
     147             : 
     148             :         // XEventListener
     149             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
     150             :             throw( ::com::sun::star::uno::RuntimeException );
     151             : 
     152             :         // XTerminateListener
     153             :         virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
     154             :             throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException );
     155             :         virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
     156             :             throw( ::com::sun::star::uno::RuntimeException );
     157             : };
     158             : 
     159             : }
     160             : 
     161             : #endif // _DESKTOP_OFFICEIPCTHREAD_HXX_
     162             : 
     163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10