Bump version to 21.06.18.1
[LibreOffice.git] / desktop / inc / dp_misc.h
blob2953cd53cfde570754ec444f447ad475bce38cd5
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 #pragma once
22 #include <osl/mutex.hxx>
23 #include <osl/process.h>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <com/sun/star/lang/XComponent.hpp>
26 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
27 #include <dp_misc_api.hxx>
29 namespace dp_misc {
31 const char CR = 0x0d;
32 const char LF = 0x0a;
35 class MutexHolder
37 mutable ::osl::Mutex m_mutex;
38 protected:
39 ::osl::Mutex & getMutex() const { return m_mutex; }
43 inline void try_dispose( css::uno::Reference< css::uno::XInterface> const & x )
45 css::uno::Reference< css::lang::XComponent> xComp( x, css::uno::UNO_QUERY );
46 if (xComp.is())
47 xComp->dispose();
53 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
54 OUString expandUnoRcTerm( OUString const & term );
56 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
57 OUString makeRcTerm( OUString const & url );
60 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
61 OUString expandUnoRcUrl( OUString const & url );
65 /** appends a relative path to a url.
67 The relative path must already be correctly encoded for use in a URL.
68 If the URL starts with vnd.sun.star.expand then the relative path will
69 be again encoded for use in an "expand" URL.
71 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString makeURL(
72 OUString const & baseURL, OUString const & relPath );
75 /** appends a relative path to a url.
77 This is the same as makeURL, but the relative Path must me a segment
78 of an system path.
80 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString makeURLAppendSysPathSegment(
81 OUString const & baseURL, OUString const & relPath );
84 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString generateRandomPipeId();
86 class AbortChannel;
88 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
89 css::uno::Reference< css::uno::XInterface> resolveUnoURL(
90 OUString const & connectString,
91 css::uno::Reference< css::uno::XComponentContext> const & xLocalContext,
92 AbortChannel const * abortChannel = nullptr );
95 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool office_is_running();
98 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
99 oslProcess raiseProcess( OUString const & appURL,
100 css::uno::Sequence< OUString > const & args );
104 /** writes the argument string to the console.
105 It converts the UTF16 string to an ANSI string using osl_getThreadTextEncoding()
106 as target encoding.
108 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
109 void writeConsole(OUString const & sText);
111 /** writes the argument to the console using the error stream.
112 Otherwise the same as writeConsole.
114 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
115 void writeConsoleError(OUString const & sText);
118 /** reads from the console.
119 It uses fgets to read char values and converts them to OUString using
120 osl_getThreadTextEncoding as target encoding. The returned string has a maximum size of
121 1024 and does NOT include leading and trailing white space(applied OUString::trim())
123 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
124 OUString readConsole();
126 /** print the text to the console in a debug build.
127 The argument is forwarded to writeConsole. The function does not add new line.
128 The code is only executed if OSL_DEBUG_LEVEL > 1
130 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
131 void TRACE(OUString const & sText);
133 /** registers or revokes shared or bundled extensions which have been
134 recently added or removed.
136 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
137 void syncRepositories(
138 bool force,
139 css::uno::Reference<
140 css::ucb::XCommandEnvironment> const & xCmdEnv);
142 /** workaround: for some reason the bridge threads which communicate with the
143 uno.exe process are not released on time
145 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
146 void disposeBridges(
147 css::uno::Reference< css::uno::XComponentContext >
148 const & ctx);
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */