Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svl/source/config/cjkoptions.cxx
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
#include <svl/cjkoptions.hxx>
21
22
#include <svl/languageoptions.hxx>
23
#include <i18nlangtag/lang.h>
24
#include <i18nlangtag/languagetag.hxx>
25
#include <officecfg/System.hxx>
26
#include <officecfg/Office/Common.hxx>
27
#include <mutex>
28
29
static void SvtCJKOptions_Load();
30
31
namespace SvtCJKOptions
32
{
33
34
bool IsCJKFontEnabled()
35
0
{
36
0
    SvtCJKOptions_Load();
37
38
    // tdf#168719: The CJK font can no longer be disabled
39
0
    return true;
40
0
}
41
42
bool IsVerticalTextEnabled()
43
0
{
44
0
    SvtCJKOptions_Load();
45
46
    // tdf#168719: The CJK font can no longer be disabled
47
0
    return true;
48
0
}
49
50
bool IsAsianTypographyEnabled()
51
0
{
52
0
    SvtCJKOptions_Load();
53
54
    // tdf#168719: The CJK font can no longer be disabled
55
0
    return true;
56
0
}
57
58
bool IsJapaneseFindEnabled()
59
0
{
60
0
    SvtCJKOptions_Load();
61
62
    // tdf#168719: The CJK font can no longer be disabled
63
0
    return true;
64
0
}
65
66
bool IsRubyEnabled()
67
0
{
68
0
    SvtCJKOptions_Load();
69
70
    // tdf#168719: The CJK font can no longer be disabled
71
0
    return true;
72
0
}
73
74
bool IsChangeCaseMapEnabled()
75
0
{
76
0
    SvtCJKOptions_Load();
77
78
    // tdf#168719: The CJK font can no longer be disabled
79
0
    return true;
80
0
}
81
82
bool IsDoubleLinesEnabled()
83
0
{
84
0
    SvtCJKOptions_Load();
85
86
    // tdf#168719: The CJK font can no longer be disabled
87
0
    return true;
88
0
}
89
90
bool    IsAnyEnabled()
91
0
{
92
0
    SvtCJKOptions_Load();
93
0
    return  IsCJKFontEnabled() || IsVerticalTextEnabled() || IsAsianTypographyEnabled() || IsJapaneseFindEnabled() ||
94
0
                IsRubyEnabled() || IsChangeCaseMapEnabled() || IsDoubleLinesEnabled() ;
95
0
}
96
97
} // namespace SvtCJKOptions
98
99
100
static std::once_flag gLoadFlag;
101
102
static void SvtCJKOptions_Load()
103
0
{
104
0
    std::call_once(gLoadFlag,
105
0
        []()
106
0
        {
107
0
            if (officecfg::Office::Common::I18N::CJK::CJKFont::get())
108
0
                return;
109
110
0
            SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM);
111
            //system locale is CJK
112
0
            bool bAutoEnableCJK = bool(nScriptType & SvtScriptType::ASIAN);
113
114
0
            if (!bAutoEnableCJK)
115
0
            {
116
                //windows secondary system locale is CJK
117
0
                OUString sWin16SystemLocale = officecfg::System::L10N::SystemLocale::get();
118
0
                LanguageType eSystemLanguage = LANGUAGE_NONE;
119
0
                if( !sWin16SystemLocale.isEmpty() )
120
0
                    eSystemLanguage = LanguageTag::convertToLanguageTypeWithFallback( sWin16SystemLocale );
121
0
                if (eSystemLanguage != LANGUAGE_SYSTEM)
122
0
                {
123
0
                    SvtScriptType nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage );
124
0
                    bAutoEnableCJK = bool(nWinScript & SvtScriptType::ASIAN);
125
0
                }
126
127
                //CJK keyboard is installed
128
0
                if (!bAutoEnableCJK)
129
0
                    bAutoEnableCJK = SvtSystemLanguageOptions::isCJKKeyboardLayoutInstalled();
130
0
            }
131
132
0
            if (bAutoEnableCJK)
133
0
            {
134
0
                std::shared_ptr<comphelper::ConfigurationChanges> xChanges(comphelper::ConfigurationChanges::create());
135
0
                officecfg::Office::Common::I18N::CJK::CJKFont::set(true, xChanges);
136
0
                officecfg::Office::Common::I18N::CJK::VerticalText::set(true, xChanges);
137
0
                officecfg::Office::Common::I18N::CJK::AsianTypography::set(true, xChanges);
138
0
                officecfg::Office::Common::I18N::CJK::JapaneseFind::set(true, xChanges);
139
0
                officecfg::Office::Common::I18N::CJK::Ruby::set(true, xChanges);
140
0
                officecfg::Office::Common::I18N::CJK::ChangeCaseMap::set(true, xChanges);
141
0
                officecfg::Office::Common::I18N::CJK::DoubleLines::set(true, xChanges);
142
0
                xChanges->commit();
143
0
            }
144
0
        });
145
0
}
146
147
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */