LibreOffice Module sc (master)  1
numformat.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 <numformat.hxx>
21 #include <patattr.hxx>
22 #include <scitems.hxx>
23 #include <document.hxx>
24 
26 #include <svl/zforlist.hxx>
27 #include <svl/zformat.hxx>
28 #include <svl/intitem.hxx>
29 #include <svl/languageoptions.hxx>
30 
31 namespace sc {
32 
34 {
35  SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
36  sal_uInt32 nKey = rPat.GetNumberFormat(pFormatter);
37  return isLatinScript(nKey, rDoc);
38 }
39 
41 {
42  SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
43  const SvNumberformat* pFormat = pFormatter->GetEntry(nFormat);
44  if (!pFormat || !pFormat->IsStandard())
45  return false;
46 
47  // The standard format is all-latin if the decimal separator doesn't
48  // have a different script type
49 
50  OUString aDecSep;
51  LanguageType nFormatLang = pFormat->GetLanguage();
52  if (nFormatLang == LANGUAGE_SYSTEM)
54  else
55  {
56  LocaleDataWrapper aLocaleData(
58  aDecSep = aLocaleData.getNumDecimalSep();
59  }
60 
61  SvtScriptType nScript = rDoc.GetStringScriptType(aDecSep);
62  return (nScript == SvtScriptType::NONE || nScript == SvtScriptType::LATIN);
63 }
64 
65 }
66 
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uIntPtr sal_uLong
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
Definition: documen6.cxx:76
const OUString & getNumDecimalSep() const
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:438
SvtScriptType
bool IsStandard() const
#define LANGUAGE_SYSTEM
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
Definition: patattr.cxx:1257
static SC_DLLPUBLIC const LocaleDataWrapper * getLocaleDataPtr()
Definition: global.cxx:1001
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
Reference< XComponentContext > getProcessComponentContext()
static bool isLatinScript(const ScPatternAttr &rPat, ScDocument &rDoc)
Check if the attribute pattern has a number format that only produces latin script output...
Definition: numformat.cxx:33
LanguageType GetLanguage() const