Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/vcl/unx/generic/app/gensys.cxx
Line
Count
Source (jump to first uncovered line)
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
#include <config_folders.h>
21
22
#include <unx/gensys.h>
23
24
#include <svdata.hxx>
25
26
#include <rtl/strbuf.hxx>
27
#include <rtl/bootstrap.hxx>
28
#include <osl/process.h>
29
#include <osl/thread.h>
30
#include <unotools/configmgr.hxx>
31
32
SalGenericSystem::SalGenericSystem()
33
0
{
34
0
}
35
36
SalGenericSystem::~SalGenericSystem()
37
0
{
38
0
}
39
40
int SalGenericSystem::ShowNativeMessageBox( const OUString& rTitle, const OUString& rMessage )
41
0
{
42
0
    std::vector< OUString > aButtons;
43
0
    int nButtonIds[5] = {0}, nBut = 0;
44
45
0
    ImplHideSplash();
46
47
0
    aButtons.push_back( u"OK"_ustr );
48
0
    nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK;
49
0
    int nResult = ShowNativeDialog( rTitle, rMessage, aButtons );
50
51
0
    return nResult != -1 ? nButtonIds[ nResult ] : 0;
52
0
}
53
54
#if !defined(ANDROID) && !defined(IOS)
55
56
// X11-specific
57
58
const char* SalGenericSystem::getFrameResName()
59
0
{
60
    /*  according to ICCCM:
61
     *  first search command line for -name parameter
62
     *  then try RESOURCE_NAME environment variable
63
     *  then use argv[0] stripped by directories
64
     */
65
0
    static OStringBuffer aResName;
66
0
    if( aResName.isEmpty() )
67
0
    {
68
0
        int nArgs = osl_getCommandArgCount();
69
0
        for( int n = 0; n < nArgs-1; n++ )
70
0
        {
71
0
            OUString aArg;
72
0
            osl_getCommandArg( n, &aArg.pData );
73
0
            if( aArg.equalsIgnoreAsciiCase("-name") )
74
0
            {
75
0
                osl_getCommandArg( n+1, &aArg.pData );
76
0
                aResName.append( OUStringToOString( aArg, osl_getThreadTextEncoding() ) );
77
0
                break;
78
0
            }
79
0
        }
80
0
        if( aResName.isEmpty() )
81
0
        {
82
0
            const char* pEnv = getenv( "RESOURCE_NAME" );
83
0
            if( pEnv && *pEnv )
84
0
                aResName.append( pEnv );
85
0
        }
86
0
        if( aResName.isEmpty() )
87
0
            aResName.append( OUStringToOString( utl::ConfigManager::getProductName().toAsciiLowerCase(),
88
0
                osl_getThreadTextEncoding()));
89
0
    }
90
0
    return aResName.getStr();
91
0
}
92
93
const char* SalGenericSystem::getFrameClassName()
94
0
{
95
0
    static OStringBuffer aClassName;
96
0
    if( aClassName.isEmpty() )
97
0
    {
98
0
        OUString aIni, aProduct;
99
0
        rtl::Bootstrap::get( u"BRAND_BASE_DIR"_ustr, aIni );
100
0
        aIni += "/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap" );
101
0
        rtl::Bootstrap aBootstrap( aIni );
102
0
        aBootstrap.getFrom( u"ProductKey"_ustr, aProduct );
103
104
0
        if( !aProduct.isEmpty() )
105
0
            aClassName.append( OUStringToOString( aProduct, osl_getThreadTextEncoding() ) );
106
0
        else
107
0
            aClassName.append( OUStringToOString( utl::ConfigManager::getProductName(), osl_getThreadTextEncoding()));
108
0
    }
109
0
    return aClassName.getStr();
110
0
}
111
112
#endif
113
114
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */