GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / desktop / source / app / officeipcthread.hxx
blobff84933e744a302413292f843fbc271dd3ed1ed7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
21 #define INCLUDED_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
23 #include "sal/config.h"
25 #include <vector>
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"
39 namespace desktop
42 oslSignalAction SAL_CALL SalMainPipeExchangeSignal_impl(void* /*pData*/, oslSignalInfo* pInfo);
44 // A request for the current office
45 // that was given by command line or by IPC pipe communication.
46 struct ProcessDocumentsRequest
48 ProcessDocumentsRequest(boost::optional< OUString > const & cwdUrl):
49 aCwdUrl(cwdUrl), pcProcessed( NULL ) {}
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
68 class DispatchWatcher;
69 class OfficeIPCThread : public salhelper::Thread
71 private:
72 static rtl::Reference< OfficeIPCThread > pGlobalOfficeIPCThread;
74 osl::Pipe maPipe;
75 bool mbDowning;
76 bool mbRequestsEnabled;
77 int mnPendingRequests;
78 DispatchWatcher* mpDispatchWatcher;
80 /* condition to be set when the request has been processed */
81 ::osl::Condition cProcessed;
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;
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;
98 OfficeIPCThread();
100 virtual ~OfficeIPCThread();
102 /// Working method which should be overridden
103 virtual void execute();
105 public:
106 enum Status
108 IPC_STATUS_OK,
109 IPC_STATUS_2ND_OFFICE,
110 IPC_STATUS_PIPE_ERROR,
111 IPC_STATUS_BOOTSTRAP_ERROR
114 // controlling pipe communication during shutdown
115 static void SetDowning();
116 static void EnableRequests( bool i_bEnable = true );
117 static sal_Bool AreRequestsPending();
118 static void RequestsCompleted( int n = 1 );
119 static sal_Bool ExecuteCmdLineRequests( ProcessDocumentsRequest& );
121 // return sal_False if second office
122 static Status EnableOfficeIPCThread();
123 static void DisableOfficeIPCThread(bool join = true);
124 // start dispatching events...
125 static void SetReady(
126 rtl::Reference< OfficeIPCThread > const & pThread =
127 rtl::Reference< OfficeIPCThread >());
129 bool AreRequestsEnabled() const { return mbRequestsEnabled && ! mbDowning; }
133 class OfficeIPCThreadController : public ::cppu::WeakImplHelper2<
134 ::com::sun::star::lang::XServiceInfo,
135 ::com::sun::star::frame::XTerminateListener >
137 public:
138 OfficeIPCThreadController() {}
139 virtual ~OfficeIPCThreadController() {}
141 // XServiceInfo
142 virtual OUString SAL_CALL getImplementationName()
143 throw ( ::com::sun::star::uno::RuntimeException );
144 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
145 throw ( ::com::sun::star::uno::RuntimeException );
146 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
147 throw ( ::com::sun::star::uno::RuntimeException );
149 // XEventListener
150 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
151 throw( ::com::sun::star::uno::RuntimeException );
153 // XTerminateListener
154 virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
155 throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException );
156 virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
157 throw( ::com::sun::star::uno::RuntimeException );
162 #endif // INCLUDED_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */