Line data Source code
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 <numformat.hxx>
21 : #include <patattr.hxx>
22 : #include <scitems.hxx>
23 : #include <document.hxx>
24 :
25 : #include <svl/zforlist.hxx>
26 : #include <svl/zformat.hxx>
27 : #include <svl/intitem.hxx>
28 : #include <svl/languageoptions.hxx>
29 :
30 : namespace sc {
31 :
32 1531 : bool NumFmtUtil::isLatinScript( const ScPatternAttr& rPat, ScDocument& rDoc )
33 : {
34 1531 : SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
35 1531 : sal_uInt32 nKey = rPat.GetNumberFormat(pFormatter);
36 1531 : return isLatinScript(nKey, rDoc);
37 : }
38 :
39 2277 : bool NumFmtUtil::isLatinScript( sal_uLong nFormat, ScDocument& rDoc )
40 : {
41 2277 : SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
42 2277 : const SvNumberformat* pFormat = pFormatter->GetEntry(nFormat);
43 2277 : if (!pFormat || !pFormat->IsStandard())
44 158 : return false;
45 :
46 : // The standard format is all-latin if the decimal separator doesn't
47 : // have a different script type
48 :
49 2119 : OUString aDecSep;
50 2119 : LanguageType nFormatLang = pFormat->GetLanguage();
51 2119 : if (nFormatLang == LANGUAGE_SYSTEM)
52 2115 : aDecSep = ScGlobal::pLocaleData->getNumDecimalSep();
53 : else
54 : {
55 : LocaleDataWrapper aLocaleData(
56 4 : comphelper::getProcessComponentContext(), LanguageTag(nFormatLang));
57 4 : aDecSep = aLocaleData.getNumDecimalSep();
58 : }
59 :
60 2119 : SvtScriptType nScript = rDoc.GetStringScriptType(aDecSep);
61 2119 : return (nScript == SvtScriptType::NONE || nScript == SvtScriptType::LATIN);
62 : }
63 :
64 156 : }
65 :
66 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|