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