xref: /trunk/main/sc/source/core/tool/zforauto.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svl/zforlist.hxx>
28cdf0e10cSrcweir #include <svl/zformat.hxx>
29cdf0e10cSrcweir #include <vcl/svapp.hxx>
30cdf0e10cSrcweir #include <tools/debug.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "zforauto.hxx"
33cdf0e10cSrcweir #include "global.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir static const sal_Char __FAR_DATA pStandardName[] = "Standard";
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //------------------------------------------------------------------------
38cdf0e10cSrcweir 
ScNumFormatAbbrev()39cdf0e10cSrcweir ScNumFormatAbbrev::ScNumFormatAbbrev() :
40cdf0e10cSrcweir     sFormatstring   ( RTL_CONSTASCII_USTRINGPARAM( pStandardName ) ),
41cdf0e10cSrcweir     eLnge           (LANGUAGE_SYSTEM),
42cdf0e10cSrcweir     eSysLnge        (LANGUAGE_GERMAN)       // sonst passt "Standard" nicht
43cdf0e10cSrcweir {
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
ScNumFormatAbbrev(const ScNumFormatAbbrev & aFormat)46cdf0e10cSrcweir ScNumFormatAbbrev::ScNumFormatAbbrev(const ScNumFormatAbbrev& aFormat) :
47cdf0e10cSrcweir     sFormatstring   (aFormat.sFormatstring),
48cdf0e10cSrcweir     eLnge           (aFormat.eLnge),
49cdf0e10cSrcweir     eSysLnge        (aFormat.eSysLnge)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
ScNumFormatAbbrev(sal_uLong nFormat,SvNumberFormatter & rFormatter)53cdf0e10cSrcweir ScNumFormatAbbrev::ScNumFormatAbbrev(sal_uLong nFormat,
54cdf0e10cSrcweir                                      SvNumberFormatter& rFormatter)
55cdf0e10cSrcweir {
56cdf0e10cSrcweir     PutFormatIndex(nFormat, rFormatter);
57cdf0e10cSrcweir }
58cdf0e10cSrcweir 
Load(SvStream & rStream,CharSet eByteStrSet)59cdf0e10cSrcweir void ScNumFormatAbbrev::Load( SvStream& rStream, CharSet eByteStrSet )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir     sal_uInt16 nSysLang, nLang;
62cdf0e10cSrcweir     rStream.ReadByteString( sFormatstring, eByteStrSet );
63cdf0e10cSrcweir     rStream >> nSysLang >> nLang;
64cdf0e10cSrcweir     eLnge = (LanguageType) nLang;
65cdf0e10cSrcweir     eSysLnge = (LanguageType) nSysLang;
66cdf0e10cSrcweir     if ( eSysLnge == LANGUAGE_SYSTEM )          // old versions did write it
67cdf0e10cSrcweir         eSysLnge = Application::GetSettings().GetLanguage();
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
Save(SvStream & rStream,CharSet eByteStrSet) const70cdf0e10cSrcweir void ScNumFormatAbbrev::Save( SvStream& rStream, CharSet eByteStrSet ) const
71cdf0e10cSrcweir {
72cdf0e10cSrcweir     rStream.WriteByteString( sFormatstring, eByteStrSet );
73cdf0e10cSrcweir     rStream << (sal_uInt16) eSysLnge << (sal_uInt16) eLnge;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
PutFormatIndex(sal_uLong nFormat,SvNumberFormatter & rFormatter)76cdf0e10cSrcweir void ScNumFormatAbbrev::PutFormatIndex(sal_uLong nFormat,
77cdf0e10cSrcweir                                        SvNumberFormatter& rFormatter)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir     const SvNumberformat* pFormat = rFormatter.GetEntry(nFormat);
80cdf0e10cSrcweir     if (pFormat)
81cdf0e10cSrcweir     {
82cdf0e10cSrcweir         eSysLnge = Application::GetSettings().GetLanguage();
83cdf0e10cSrcweir         eLnge = pFormat->GetLanguage();
84cdf0e10cSrcweir         sFormatstring = ((SvNumberformat*)pFormat)->GetFormatstring();
85cdf0e10cSrcweir     }
86cdf0e10cSrcweir     else
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir         DBG_ERROR("SCNumFormatAbbrev:: unbekanntes Zahlformat");
89cdf0e10cSrcweir         eLnge = LANGUAGE_SYSTEM;
90cdf0e10cSrcweir         eSysLnge = LANGUAGE_GERMAN;     // sonst passt "Standard" nicht
91cdf0e10cSrcweir         sFormatstring.AssignAscii( RTL_CONSTASCII_STRINGPARAM( pStandardName ) );
92cdf0e10cSrcweir     }
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
GetFormatIndex(SvNumberFormatter & rFormatter)95cdf0e10cSrcweir sal_uLong ScNumFormatAbbrev::GetFormatIndex( SvNumberFormatter& rFormatter)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     short nType;
98cdf0e10cSrcweir     sal_Bool bNewInserted;
99cdf0e10cSrcweir     xub_StrLen nCheckPos;
100cdf0e10cSrcweir     return rFormatter.GetIndexPuttingAndConverting( sFormatstring, eLnge,
101cdf0e10cSrcweir             eSysLnge, nType, bNewInserted, nCheckPos);
102cdf0e10cSrcweir }
103