Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/unotools/resmgr.hxx
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
#ifndef INCLUDED_UNOTOOLS_RESMGR_HXX
20
#define INCLUDED_UNOTOOLS_RESMGR_HXX
21
22
#include <config_options.h>
23
#include <unotools/unotoolsdllapi.h>
24
#include <unotools/syslocale.hxx>
25
#include <rtl/ustring.hxx>
26
#include <string_view>
27
28
class LanguageTag;
29
30
typedef OUString (*ResHookProc)(const OUString& rStr);
31
32
struct UNOTOOLS_DLLPUBLIC TranslateId
33
{
34
    const char* mpContext = nullptr;
35
    const char8_t* mpId = nullptr;
36
37
1.07M
    constexpr TranslateId() = default;
38
39
    TranslateId(const char* pContext, const char* pId)
40
19.0k
        : mpContext(pContext)
41
19.0k
        , mpId(reinterpret_cast<char8_t const *>(pId))
42
19.0k
    {}
43
44
    constexpr TranslateId(const char* pContext, const char8_t* pId)
45
11.5M
        : mpContext(pContext)
46
11.5M
        , mpId(pId)
47
11.5M
    {}
48
49
13.1M
    char const * getId() const { return reinterpret_cast<char const *>(mpId); }
50
51
1.80M
    operator bool() const { return mpId != nullptr; }
52
53
    bool operator==(const TranslateId& other) const;
54
};
55
56
struct UNLESS_MERGELIBS(UNOTOOLS_DLLPUBLIC) TranslateNId
57
{
58
    const char* mpContext = nullptr;
59
    const char* mpSingular = nullptr;
60
    const char* mpPlural = nullptr;
61
62
    TranslateNId() = default;
63
64
    TranslateNId(const char* pContext, const char* pSingular, const char* pPlural)
65
        : mpContext(pContext)
66
        , mpSingular(pSingular)
67
        , mpPlural(pPlural)
68
0
    {}
69
70
0
    operator bool() const { return mpContext != nullptr; }
71
72
    bool operator==(const TranslateNId& other) const;
73
};
74
75
namespace Translate
76
{
77
    UNOTOOLS_DLLPUBLIC std::locale Create(std::string_view aPrefixName, const LanguageTag& rLocale = SvtSysLocale().GetUILanguageTag());
78
    UNOTOOLS_DLLPUBLIC OUString get(TranslateId sContextAndId, const std::locale &loc);
79
    UNOTOOLS_DLLPUBLIC OUString getLanguage(const std::locale& loc);
80
    UNOTOOLS_DLLPUBLIC OUString nget(TranslateNId aContextSingularPlural, int n, const std::locale &loc);
81
    UNOTOOLS_DLLPUBLIC void SetReadStringHook( ResHookProc pProc );
82
    UNOTOOLS_DLLPUBLIC ResHookProc GetReadStringHook();
83
    UNOTOOLS_DLLPUBLIC OUString ExpandVariables(const OUString& rString);
84
}
85
86
#endif
87
88
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */