Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / core / tool / zforauto.cxx
blob7dc049b0ef50d9787d98055cba9e0056797083bc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
24 #include "zforauto.hxx"
25 #include "global.hxx"
27 ScNumFormatAbbrev::ScNumFormatAbbrev() :
28 sFormatstring ( "Standard" ),
29 eLnge (LANGUAGE_SYSTEM),
30 eSysLnge (LANGUAGE_GERMAN) // sonst passt "Standard" nicht
34 ScNumFormatAbbrev::ScNumFormatAbbrev(const ScNumFormatAbbrev& aFormat) :
35 sFormatstring (aFormat.sFormatstring),
36 eLnge (aFormat.eLnge),
37 eSysLnge (aFormat.eSysLnge)
41 ScNumFormatAbbrev::ScNumFormatAbbrev(sal_uLong nFormat,
42 SvNumberFormatter& rFormatter)
44 PutFormatIndex(nFormat, rFormatter);
47 void ScNumFormatAbbrev::Load( SvStream& rStream, rtl_TextEncoding eByteStrSet )
49 sal_uInt16 nSysLang, nLang;
50 sFormatstring = rStream.ReadUniOrByteString( eByteStrSet );
51 rStream >> nSysLang >> nLang;
52 eLnge = (LanguageType) nLang;
53 eSysLnge = (LanguageType) nSysLang;
54 if ( eSysLnge == LANGUAGE_SYSTEM ) // old versions did write it
55 eSysLnge = Application::GetSettings().GetLanguageTag().getLanguageType();
58 void ScNumFormatAbbrev::Save( SvStream& rStream, rtl_TextEncoding eByteStrSet ) const
60 rStream.WriteUniOrByteString( sFormatstring, eByteStrSet );
61 rStream << (sal_uInt16) eSysLnge << (sal_uInt16) eLnge;
64 void ScNumFormatAbbrev::PutFormatIndex(sal_uLong nFormat,
65 SvNumberFormatter& rFormatter)
67 const SvNumberformat* pFormat = rFormatter.GetEntry(nFormat);
68 if (pFormat)
70 eSysLnge = Application::GetSettings().GetLanguageTag().getLanguageType();
71 eLnge = pFormat->GetLanguage();
72 sFormatstring = ((SvNumberformat*)pFormat)->GetFormatstring();
74 else
76 OSL_FAIL("SCNumFormatAbbrev:: unknown number format");
77 eLnge = LANGUAGE_SYSTEM;
78 eSysLnge = LANGUAGE_GERMAN; // sonst passt "Standard" nicht
79 sFormatstring = "Standard";
83 sal_uLong ScNumFormatAbbrev::GetFormatIndex( SvNumberFormatter& rFormatter)
85 short nType;
86 bool bNewInserted;
87 sal_Int32 nCheckPos;
88 return rFormatter.GetIndexPuttingAndConverting( sFormatstring, eLnge,
89 eSysLnge, nType, bNewInserted, nCheckPos);
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */