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 :
21 : #include <svl/zforlist.hxx>
22 : #include <svl/zformat.hxx>
23 : #include <vcl/svapp.hxx>
24 :
25 : #include "zforauto.hxx"
26 : #include "global.hxx"
27 :
28 : static const sal_Char pStandardName[] = "Standard";
29 :
30 : //------------------------------------------------------------------------
31 :
32 0 : ScNumFormatAbbrev::ScNumFormatAbbrev() :
33 : sFormatstring ( RTL_CONSTASCII_USTRINGPARAM( pStandardName ) ),
34 : eLnge (LANGUAGE_SYSTEM),
35 0 : eSysLnge (LANGUAGE_GERMAN) // sonst passt "Standard" nicht
36 : {
37 0 : }
38 :
39 0 : ScNumFormatAbbrev::ScNumFormatAbbrev(const ScNumFormatAbbrev& aFormat) :
40 : sFormatstring (aFormat.sFormatstring),
41 : eLnge (aFormat.eLnge),
42 0 : eSysLnge (aFormat.eSysLnge)
43 : {
44 0 : }
45 :
46 0 : ScNumFormatAbbrev::ScNumFormatAbbrev(sal_uLong nFormat,
47 0 : SvNumberFormatter& rFormatter)
48 : {
49 0 : PutFormatIndex(nFormat, rFormatter);
50 0 : }
51 :
52 0 : void ScNumFormatAbbrev::Load( SvStream& rStream, CharSet eByteStrSet )
53 : {
54 : sal_uInt16 nSysLang, nLang;
55 0 : sFormatstring = rStream.ReadUniOrByteString( eByteStrSet );
56 0 : rStream >> nSysLang >> nLang;
57 0 : eLnge = (LanguageType) nLang;
58 0 : eSysLnge = (LanguageType) nSysLang;
59 0 : if ( eSysLnge == LANGUAGE_SYSTEM ) // old versions did write it
60 0 : eSysLnge = Application::GetSettings().GetLanguageTag().getLanguageType();
61 0 : }
62 :
63 0 : void ScNumFormatAbbrev::Save( SvStream& rStream, CharSet eByteStrSet ) const
64 : {
65 0 : rStream.WriteUniOrByteString( sFormatstring, eByteStrSet );
66 0 : rStream << (sal_uInt16) eSysLnge << (sal_uInt16) eLnge;
67 0 : }
68 :
69 0 : void ScNumFormatAbbrev::PutFormatIndex(sal_uLong nFormat,
70 : SvNumberFormatter& rFormatter)
71 : {
72 0 : const SvNumberformat* pFormat = rFormatter.GetEntry(nFormat);
73 0 : if (pFormat)
74 : {
75 0 : eSysLnge = Application::GetSettings().GetLanguageTag().getLanguageType();
76 0 : eLnge = pFormat->GetLanguage();
77 0 : sFormatstring = ((SvNumberformat*)pFormat)->GetFormatstring();
78 : }
79 : else
80 : {
81 : OSL_FAIL("SCNumFormatAbbrev:: unbekanntes Zahlformat");
82 0 : eLnge = LANGUAGE_SYSTEM;
83 0 : eSysLnge = LANGUAGE_GERMAN; // sonst passt "Standard" nicht
84 0 : sFormatstring.AssignAscii( RTL_CONSTASCII_STRINGPARAM( pStandardName ) );
85 : }
86 0 : }
87 :
88 0 : sal_uLong ScNumFormatAbbrev::GetFormatIndex( SvNumberFormatter& rFormatter)
89 : {
90 : short nType;
91 : bool bNewInserted;
92 : xub_StrLen nCheckPos;
93 : return rFormatter.GetIndexPuttingAndConverting( sFormatstring, eLnge,
94 0 : eSysLnge, nType, bNewInserted, nCheckPos);
95 : }
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|