Update ooo320-m1
[ooovba.git] / sc / source / core / tool / zforauto.cxx
blob64a39ffda45695b1b5af9ae1fbceb7df4129f849
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: zforauto.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include <svtools/zforlist.hxx>
35 #include <svtools/zformat.hxx>
36 #include <vcl/svapp.hxx>
37 #include <tools/debug.hxx>
39 #include "zforauto.hxx"
40 #include "global.hxx"
42 static const sal_Char __FAR_DATA pStandardName[] = "Standard";
44 //------------------------------------------------------------------------
46 ScNumFormatAbbrev::ScNumFormatAbbrev() :
47 sFormatstring ( RTL_CONSTASCII_USTRINGPARAM( pStandardName ) ),
48 eLnge (LANGUAGE_SYSTEM),
49 eSysLnge (LANGUAGE_GERMAN) // sonst passt "Standard" nicht
53 ScNumFormatAbbrev::ScNumFormatAbbrev(const ScNumFormatAbbrev& aFormat) :
54 sFormatstring (aFormat.sFormatstring),
55 eLnge (aFormat.eLnge),
56 eSysLnge (aFormat.eSysLnge)
60 ScNumFormatAbbrev::ScNumFormatAbbrev(ULONG nFormat,
61 SvNumberFormatter& rFormatter)
63 PutFormatIndex(nFormat, rFormatter);
66 void ScNumFormatAbbrev::Load( SvStream& rStream, CharSet eByteStrSet )
68 USHORT nSysLang, nLang;
69 rStream.ReadByteString( sFormatstring, eByteStrSet );
70 rStream >> nSysLang >> nLang;
71 eLnge = (LanguageType) nLang;
72 eSysLnge = (LanguageType) nSysLang;
73 if ( eSysLnge == LANGUAGE_SYSTEM ) // old versions did write it
74 eSysLnge = Application::GetSettings().GetLanguage();
77 void ScNumFormatAbbrev::Save( SvStream& rStream, CharSet eByteStrSet ) const
79 rStream.WriteByteString( sFormatstring, eByteStrSet );
80 rStream << (USHORT) eSysLnge << (USHORT) eLnge;
83 void ScNumFormatAbbrev::PutFormatIndex(ULONG nFormat,
84 SvNumberFormatter& rFormatter)
86 const SvNumberformat* pFormat = rFormatter.GetEntry(nFormat);
87 if (pFormat)
89 eSysLnge = Application::GetSettings().GetLanguage();
90 eLnge = pFormat->GetLanguage();
91 sFormatstring = ((SvNumberformat*)pFormat)->GetFormatstring();
93 else
95 DBG_ERROR("SCNumFormatAbbrev:: unbekanntes Zahlformat");
96 eLnge = LANGUAGE_SYSTEM;
97 eSysLnge = LANGUAGE_GERMAN; // sonst passt "Standard" nicht
98 sFormatstring.AssignAscii( RTL_CONSTASCII_STRINGPARAM( pStandardName ) );
102 ULONG ScNumFormatAbbrev::GetFormatIndex( SvNumberFormatter& rFormatter)
104 short nType;
105 BOOL bNewInserted;
106 xub_StrLen nCheckPos;
107 return rFormatter.GetIndexPuttingAndConverting( sFormatstring, eLnge,
108 eSysLnge, nType, bNewInserted, nCheckPos);