LibreOffice Module svl (master) 1
cjkoptions.cxx
Go to the documentation of this file.
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
23#include <i18nlangtag/lang.h>
25#include <officecfg/System.hxx>
26#include <officecfg/Office/Common.hxx>
27#include <mutex>
28
29using namespace ::com::sun::star::uno;
30
31static void SvtCJKOptions_Load();
32
34{
35
37{
39 return officecfg::Office::Common::I18N::CJK::CJKFont::get();
40}
41
43{
45 return officecfg::Office::Common::I18N::CJK::VerticalText::get();
46}
47
49{
51 return officecfg::Office::Common::I18N::CJK::AsianTypography::get();
52}
53
55{
57 return officecfg::Office::Common::I18N::CJK::JapaneseFind::get();
58}
59
61{
63 return officecfg::Office::Common::I18N::CJK::Ruby::get();
64}
65
67{
69 return officecfg::Office::Common::I18N::CJK::ChangeCaseMap::get();
70}
71
73{
75 return officecfg::Office::Common::I18N::CJK::DoubleLines::get();
76}
77
78void SetAll(bool bSet)
79{
81 if ( officecfg::Office::Common::I18N::CJK::CJKFont::isReadOnly()
82 || officecfg::Office::Common::I18N::CJK::VerticalText::isReadOnly()
83 || officecfg::Office::Common::I18N::CJK::AsianTypography::isReadOnly()
84 || officecfg::Office::Common::I18N::CJK::JapaneseFind::isReadOnly()
85 || officecfg::Office::Common::I18N::CJK::Ruby::isReadOnly()
86 || officecfg::Office::Common::I18N::CJK::ChangeCaseMap::isReadOnly()
87 || officecfg::Office::Common::I18N::CJK::DoubleLines::isReadOnly() )
88 return;
89
90 std::shared_ptr<comphelper::ConfigurationChanges> xChanges(comphelper::ConfigurationChanges::create());
91 officecfg::Office::Common::I18N::CJK::CJKFont::set(bSet, xChanges);
92 officecfg::Office::Common::I18N::CJK::VerticalText::set(bSet, xChanges);
93 officecfg::Office::Common::I18N::CJK::AsianTypography::set(bSet, xChanges);
94 officecfg::Office::Common::I18N::CJK::JapaneseFind::set(bSet, xChanges);
95 officecfg::Office::Common::I18N::CJK::Ruby::set(bSet, xChanges);
96 officecfg::Office::Common::I18N::CJK::ChangeCaseMap::set(bSet, xChanges);
97 officecfg::Office::Common::I18N::CJK::DoubleLines::set(bSet, xChanges);
98 xChanges->commit();
99}
100
102{
106}
107
109{
111 return officecfg::Office::Common::I18N::CJK::CJKFont::isReadOnly()
112 || officecfg::Office::Common::I18N::CJK::VerticalText::isReadOnly()
113 || officecfg::Office::Common::I18N::CJK::AsianTypography::isReadOnly()
114 || officecfg::Office::Common::I18N::CJK::JapaneseFind::isReadOnly()
115 || officecfg::Office::Common::I18N::CJK::Ruby::isReadOnly()
116 || officecfg::Office::Common::I18N::CJK::ChangeCaseMap::isReadOnly()
117 || officecfg::Office::Common::I18N::CJK::DoubleLines::isReadOnly();
118}
119
120} // namespace SvtCJKOptions
121
122
123static std::once_flag gLoadFlag;
124
126{
127 std::call_once(gLoadFlag,
128 []()
129 {
130 if (officecfg::Office::Common::I18N::CJK::CJKFont::get())
131 return;
132
134 //system locale is CJK
135 bool bAutoEnableCJK = bool(nScriptType & SvtScriptType::ASIAN);
136
137 if (!bAutoEnableCJK)
138 {
139 //windows secondary system locale is CJK
140 OUString sWin16SystemLocale = officecfg::System::L10N::SystemLocale::get();
141 LanguageType eSystemLanguage = LANGUAGE_NONE;
142 if( !sWin16SystemLocale.isEmpty() )
143 eSystemLanguage = LanguageTag::convertToLanguageTypeWithFallback( sWin16SystemLocale );
144 if (eSystemLanguage != LANGUAGE_SYSTEM)
145 {
146 SvtScriptType nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage );
147 bAutoEnableCJK = bool(nWinScript & SvtScriptType::ASIAN);
148 }
149
150 //CJK keyboard is installed
151 if (!bAutoEnableCJK)
153 }
154
155 if (bAutoEnableCJK)
156 {
157 std::shared_ptr<comphelper::ConfigurationChanges> xChanges(comphelper::ConfigurationChanges::create());
158 officecfg::Office::Common::I18N::CJK::CJKFont::set(true, xChanges);
159 officecfg::Office::Common::I18N::CJK::VerticalText::set(true, xChanges);
160 officecfg::Office::Common::I18N::CJK::AsianTypography::set(true, xChanges);
161 officecfg::Office::Common::I18N::CJK::JapaneseFind::set(true, xChanges);
162 officecfg::Office::Common::I18N::CJK::Ruby::set(true, xChanges);
163 officecfg::Office::Common::I18N::CJK::ChangeCaseMap::set(true, xChanges);
164 officecfg::Office::Common::I18N::CJK::DoubleLines::set(true, xChanges);
165 xChanges->commit();
166 }
167 });
168}
169
170/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::once_flag gLoadFlag
Definition: cjkoptions.cxx:123
static void SvtCJKOptions_Load()
Definition: cjkoptions.cxx:125
static LanguageType convertToLanguageTypeWithFallback(const OUString &rBcp47)
static std::shared_ptr< ConfigurationChanges > create()
#define LANGUAGE_SYSTEM
#define LANGUAGE_NONE
SvtScriptType
bool IsVerticalTextEnabled()
Definition: cjkoptions.cxx:42
bool IsCJKFontEnabled()
Definition: cjkoptions.cxx:36
bool IsAnyReadOnly()
Definition: cjkoptions.cxx:108
bool IsChangeCaseMapEnabled()
Definition: cjkoptions.cxx:66
bool IsJapaneseFindEnabled()
Definition: cjkoptions.cxx:54
void SetAll(bool bSet)
Definition: cjkoptions.cxx:78
bool IsDoubleLinesEnabled()
Definition: cjkoptions.cxx:72
bool IsAsianTypographyEnabled()
Definition: cjkoptions.cxx:48
bool IsRubyEnabled()
Definition: cjkoptions.cxx:60
bool IsAnyEnabled()
Definition: cjkoptions.cxx:101
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)