LibreOffice Module desktop (master)  1
officeipcthread.hxx
Go to the documentation of this file.
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/signal.h>
30 #include <rtl/ref.hxx>
31 #include <rtl/ustring.hxx>
33 #include <cppuhelper/implbase.hxx>
34 #include <osl/conditn.hxx>
35 #include <optional>
36 
37 namespace desktop
38 {
39 
40 oslSignalAction SalMainPipeExchangeSignal_impl(void* /*pData*/, oslSignalInfo* pInfo);
41 
42 // A request for the current office
43 // that was given by command line or by IPC pipe communication.
45 {
46  explicit ProcessDocumentsRequest(std::optional< OUString > const & cwdUrl):
47  aCwdUrl(cwdUrl), pcProcessed( nullptr ), bTextCat( false ), bScriptCat( false ) {}
48 
49  std::optional< OUString > aCwdUrl;
50  OUString aModule;
51  std::vector< OUString > aOpenList; // Documents that should be opened in the default way
52  std::vector< OUString > aViewList; // Documents that should be opened in viewmode
53  std::vector< OUString > aStartList; // Documents/Presentations that should be started
54  std::vector< OUString > aPrintList; // Documents that should be printed on default printer
55  std::vector< OUString > aForceOpenList; // Documents that should be forced to open for editing (even templates)
56  std::vector< OUString > aForceNewList; // Documents that should be forced to create a new document
57  OUString aPrinterName; // The printer name that should be used for printing
58  std::vector< OUString > aPrintToList; // Documents that should be printed on the given printer
59  std::vector< OUString > aConversionList;
61  OUString aConversionOut;
63  std::vector< OUString > aInFilter;
64  ::osl::Condition *pcProcessed; // pointer condition to be set when the request has been processed
65  bool* mpbSuccess = nullptr; // pointer to boolean receiving if the processing was successful
66  bool bTextCat; // boolean flag indicating whether to dump text content to console
67  bool bScriptCat; // boolean flag indicating whether to dump script content to console
68 };
69 
70 class DispatchWatcher;
71 class IpcThread;
72 class PipeIpcThread;
73 class DbusIpcThread;
74 
76 {
77  friend IpcThread;
78  friend PipeIpcThread;
79  friend DbusIpcThread;
80 
81  private:
83 
85 
90 
91  /* condition to be set when the request has been processed */
92  ::osl::Condition cProcessed;
93  /* receives if the processing was successful (may be false e.g. when shutting down) */
94  bool mbSuccess = false;
95 
96  /* condition to be set when the main event loop is ready
97  otherwise an error dialogs event loop could eat away
98  requests from a 2nd office */
99  ::osl::Condition cReady;
100 
101  static ::osl::Mutex& GetMutex();
102 
103  RequestHandler();
104 
105  virtual ~RequestHandler() override;
106 
107  public:
108  enum Status
109  {
114  };
115 
116  // controlling pipe communication during shutdown
117  static void SetDowning();
118  static void EnableRequests();
119  static bool AreRequestsPending();
120  static void RequestsCompleted();
121  static bool ExecuteCmdLineRequests(
122  ProcessDocumentsRequest&, bool noTerminate);
123 
124  // return sal_False if second office
125  static Status Enable(bool ipc);
126  static void Disable();
127  // start dispatching events...
128  static void SetReady(bool bIsReady);
129  static void WaitForReady();
130 
131  bool AreRequestsEnabled() const { return mState == State::RequestsEnabled; }
132 };
133 
134 
135 class RequestHandlerController : public ::cppu::WeakImplHelper<
136  css::lang::XServiceInfo,
137  css::frame::XTerminateListener >
138 {
139  public:
141 
142  // XServiceInfo
143  virtual OUString SAL_CALL getImplementationName() override;
144  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
145  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
146 
147  // XEventListener
148  virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
149 
150  // XTerminateListener
151  virtual void SAL_CALL queryTermination( const css::lang::EventObject& aEvent ) override;
152  virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override;
153 };
154 
155 }
156 
157 #endif // INCLUDED_DESKTOP_SOURCE_APP_OFFICEIPCTHREAD_HXX
158 
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< IpcThread > mIpcThread
std::vector< OUString > aOpenList
static bool ExecuteCmdLineRequests(ProcessDocumentsRequest &, bool noTerminate)
std::vector< OUString > aForceNewList
ProcessDocumentsRequest(std::optional< OUString > const &cwdUrl)
Definition: app.cxx:161
std::vector< OUString > aViewList
static rtl::Reference< RequestHandler > pGlobal
virtual void SAL_CALL queryTermination(const css::lang::EventObject &aEvent) override
rtl::Reference< DispatchWatcher > mpDispatchWatcher
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL notifyTermination(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
std::vector< OUString > aForceOpenList
std::vector< OUString > aPrintToList
static bool AreRequestsPending()
static void SetReady(bool bIsReady)
unsigned char sal_Bool
virtual ~RequestHandler() override
std::vector< OUString > aConversionList
std::vector< OUString > aStartList
bool AreRequestsEnabled() const
std::optional< OUString > aCwdUrl
static Status Enable(bool ipc)
std::vector< OUString > aPrintList
::osl::Condition cProcessed
std::vector< OUString > aInFilter
oslSignalAction SalMainPipeExchangeSignal_impl(SAL_UNUSED_PARAMETER void *, oslSignalInfo *pInfo)