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 <utility>
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>
34#include <osl/conditn.hxx>
35#include <optional>
36
37namespace desktop
38{
39
40oslSignalAction 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 > cwdUrl):
47 aCwdUrl(std::move(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;
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
70class DispatchWatcher;
71class IpcThread;
72class PipeIpcThread;
73class DbusIpcThread;
74
76{
77 friend IpcThread;
80
81 private:
83
84 enum class State { Starting, RequestsEnabled, Downing };
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
104
105 virtual ~RequestHandler() override;
106
107 public:
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
132};
133
134
135class 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/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL queryTermination(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL notifyTermination(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
static rtl::Reference< RequestHandler > pGlobal
static Status Enable(bool ipc)
rtl::Reference< IpcThread > mIpcThread
static bool AreRequestsPending()
static void SetReady(bool bIsReady)
static bool ExecuteCmdLineRequests(ProcessDocumentsRequest &, bool noTerminate)
::osl::Condition cProcessed
rtl::Reference< DispatchWatcher > mpDispatchWatcher
virtual ~RequestHandler() override
Definition: app.cxx:165
oslSignalAction SalMainPipeExchangeSignal_impl(SAL_UNUSED_PARAMETER void *, oslSignalInfo *pInfo)
std::vector< OUString > aPrintToList
ProcessDocumentsRequest(std::optional< OUString > cwdUrl)
std::vector< OUString > aPrintList
std::vector< OUString > aConversionList
std::vector< OUString > aViewList
std::vector< OUString > aOpenList
std::vector< OUString > aStartList
std::optional< OUString > aCwdUrl
std::vector< OUString > aInFilter
std::vector< OUString > aForceNewList
std::vector< OUString > aForceOpenList
unsigned char sal_Bool