Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/desktop/inc/dp_misc.h
Line
Count
Source
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 <string_view>
25
26
#include <osl/process.h>
27
#include <com/sun/star/uno/XComponentContext.hpp>
28
#include <com/sun/star/lang/XComponent.hpp>
29
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
30
#include <dp_misc_api.hxx>
31
32
namespace dp_misc {
33
34
const char CR = 0x0d;
35
const char LF = 0x0a;
36
37
38
inline void try_dispose( css::uno::Reference< css::uno::XInterface> const & x )
39
0
{
40
0
    css::uno::Reference< css::lang::XComponent> xComp( x, css::uno::UNO_QUERY );
41
0
    if (xComp.is())
42
0
        xComp->dispose();
43
0
}
44
45
46
47
48
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
49
OUString expandUnoRcTerm( OUString const & term );
50
51
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
52
OUString makeRcTerm( OUString const & url );
53
54
55
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
56
OUString expandUnoRcUrl( OUString const & url );
57
58
59
60
/** appends a relative path to a url.
61
62
    The relative path must already be correctly encoded for use in a URL.
63
    If the URL starts with vnd.sun.star.expand then the relative path will
64
    be again encoded for use in an "expand" URL.
65
 */
66
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString makeURL(
67
    std::u16string_view baseURL, OUString const & relPath );
68
69
70
/** appends a relative path to a url.
71
72
    This is the same as makeURL, but the relative Path must me a segment
73
    of an system path.
74
 */
75
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString makeURLAppendSysPathSegment(
76
    std::u16string_view baseURL, OUString const & relPath );
77
78
79
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString generateRandomPipeId();
80
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString generateOfficePipeId();
81
82
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC void setOfficeIpcThreadRunning(bool bRunning);
83
84
class AbortChannel;
85
86
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
87
css::uno::Reference< css::uno::XInterface> resolveUnoURL(
88
    OUString const & connectString,
89
    css::uno::Reference< css::uno::XComponentContext> const & xLocalContext,
90
    AbortChannel const * abortChannel = nullptr );
91
92
// Check if office is running on this system (not necessarily in this process!)
93
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool office_is_running();
94
95
96
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
97
oslProcess raiseProcess( OUString const & appURL,
98
                         css::uno::Sequence< OUString > const & args );
99
100
101
102
/** writes the argument string to the console.
103
    It converts the UTF16 string to an ANSI string using osl_getThreadTextEncoding()
104
    as target encoding.
105
*/
106
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
107
void writeConsole(std::u16string_view sText);
108
109
/** writes the argument to the console using the error stream.
110
    Otherwise the same as writeConsole.
111
*/
112
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
113
void writeConsoleError(std::u16string_view sText);
114
115
116
/** reads from the console.
117
    It uses fgets to read char values and converts them to OUString using
118
    osl_getThreadTextEncoding as target encoding. The returned string has a maximum size of
119
    1024 and does NOT include leading and trailing white space(applied OUString::trim())
120
*/
121
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
122
OUString readConsole();
123
124
/** registers or revokes shared or bundled extensions which have been
125
    recently added or removed.
126
*/
127
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
128
void syncRepositories(
129
    bool force,
130
    css::uno::Reference<
131
        css::ucb::XCommandEnvironment> const & xCmdEnv);
132
133
/** workaround: for some reason the bridge threads which communicate with the
134
    uno.exe process are not released on time
135
*/
136
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
137
void disposeBridges(
138
    css::uno::Reference< css::uno::XComponentContext >
139
        const & ctx);
140
141
}
142
143
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */