1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svl/zforlist.hxx>
21 #include <svl/zformat.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/settings.hxx>
25 #include "zforauto.hxx"
28 ScNumFormatAbbrev::ScNumFormatAbbrev() :
29 sFormatstring ( "Standard" ),
30 eLnge (LANGUAGE_SYSTEM
),
31 eSysLnge (LANGUAGE_GERMAN
) // sonst passt "Standard" nicht
35 ScNumFormatAbbrev::ScNumFormatAbbrev(const ScNumFormatAbbrev
& aFormat
) :
36 sFormatstring (aFormat
.sFormatstring
),
37 eLnge (aFormat
.eLnge
),
38 eSysLnge (aFormat
.eSysLnge
)
42 ScNumFormatAbbrev::ScNumFormatAbbrev(sal_uLong nFormat
,
43 SvNumberFormatter
& rFormatter
)
45 PutFormatIndex(nFormat
, rFormatter
);
48 void ScNumFormatAbbrev::Load( SvStream
& rStream
, rtl_TextEncoding eByteStrSet
)
50 sal_uInt16 nSysLang
, nLang
;
51 sFormatstring
= rStream
.ReadUniOrByteString( eByteStrSet
);
52 rStream
.ReadUInt16( nSysLang
).ReadUInt16( nLang
);
53 eLnge
= (LanguageType
) nLang
;
54 eSysLnge
= (LanguageType
) nSysLang
;
55 if ( eSysLnge
== LANGUAGE_SYSTEM
) // old versions did write it
56 eSysLnge
= Application::GetSettings().GetLanguageTag().getLanguageType();
59 void ScNumFormatAbbrev::Save( SvStream
& rStream
, rtl_TextEncoding eByteStrSet
) const
61 rStream
.WriteUniOrByteString( sFormatstring
, eByteStrSet
);
62 rStream
.WriteUInt16( eSysLnge
).WriteUInt16( eLnge
);
65 void ScNumFormatAbbrev::PutFormatIndex(sal_uLong nFormat
,
66 SvNumberFormatter
& rFormatter
)
68 const SvNumberformat
* pFormat
= rFormatter
.GetEntry(nFormat
);
71 eSysLnge
= Application::GetSettings().GetLanguageTag().getLanguageType();
72 eLnge
= pFormat
->GetLanguage();
73 sFormatstring
= pFormat
->GetFormatstring();
77 OSL_FAIL("SCNumFormatAbbrev:: unknown number format");
78 eLnge
= LANGUAGE_SYSTEM
;
79 eSysLnge
= LANGUAGE_GERMAN
; // sonst passt "Standard" nicht
80 sFormatstring
= "Standard";
84 sal_uLong
ScNumFormatAbbrev::GetFormatIndex( SvNumberFormatter
& rFormatter
)
89 return rFormatter
.GetIndexPuttingAndConverting( sFormatstring
, eLnge
,
90 eSysLnge
, nType
, bNewInserted
, nCheckPos
);
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */