summaryrefslogtreecommitdiff
path: root/svl/source/numbers
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-11-06 09:42:15 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-11-06 15:56:13 +0000
commit48a4d615c85c58a06a50209bfbcc6e93145142fc (patch)
tree454e3743daa81261287a1c0acf9a721fdae5e108 /svl/source/numbers
parent9e05e45452bfc98c39f589b3f3b90c6596a638c9 (diff)
If XPersistObject support is dropped, all this unsupported old data can go
Change-Id: I7000df307920b1b04b81cc4c436009cf6b6548e0 Reviewed-on: https://gerrit.libreoffice.org/12282 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svl/source/numbers')
-rw-r--r--svl/source/numbers/numhead.cxx151
-rw-r--r--svl/source/numbers/numhead.hxx65
-rw-r--r--svl/source/numbers/zforlist.cxx140
-rw-r--r--svl/source/numbers/zformat.cxx386
-rw-r--r--svl/source/numbers/zforscan.cxx6
5 files changed, 4 insertions, 744 deletions
diff --git a/svl/source/numbers/numhead.cxx b/svl/source/numbers/numhead.cxx
deleted file mode 100644
index df521b6db1a5..000000000000
--- a/svl/source/numbers/numhead.cxx
+++ /dev/null
@@ -1,151 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <tools/debug.hxx>
-
-#include "numhead.hxx"
-
-// ID's for files:
-#define SV_NUMID_SIZES 0x4200
-
-//#pragma SEG_FUNCDEF(numhead_06)
-
-//! Synchronous with Skip()
-ImpSvNumMultipleReadHeader::ImpSvNumMultipleReadHeader(SvStream& rNewStream) :
- rStream( rNewStream )
-{
- sal_uInt32 nDataSize;
- rStream.ReadUInt32( nDataSize );
- sal_uLong nDataPos = rStream.Tell();
- nEntryEnd = nDataPos;
-
- rStream.SeekRel(nDataSize);
- sal_uInt16 nID;
- rStream.ReadUInt16( nID );
- if (nID != SV_NUMID_SIZES)
- {
- OSL_FAIL("SV_NUMID_SIZES not found");
- }
- sal_uInt32 nSizeTableLen;
- rStream.ReadUInt32( nSizeTableLen );
- pBuf = new char[nSizeTableLen];
- rStream.Read( pBuf, nSizeTableLen );
- pMemStream = new SvMemoryStream( pBuf, nSizeTableLen, STREAM_READ );
-
- nEndPos = rStream.Tell();
- rStream.Seek( nDataPos );
-}
-
-//#pragma SEG_FUNCDEF(numhead_07)
-
-ImpSvNumMultipleReadHeader::~ImpSvNumMultipleReadHeader()
-{
- DBG_ASSERT( pMemStream->Tell() == pMemStream->GetEndOfData(),
- "Sizes not completely read" );
- delete pMemStream;
- delete [] pBuf;
-
- rStream.Seek(nEndPos);
-}
-
-//#pragma SEG_FUNCDEF(numhead_08)
-
-void ImpSvNumMultipleReadHeader::EndEntry()
-{
- sal_uLong nPos = rStream.Tell();
- DBG_ASSERT( nPos <= nEntryEnd, "Read too much" );
- if ( nPos != nEntryEnd )
- rStream.Seek( nEntryEnd ); // Skip the rest
-}
-
-//#pragma SEG_FUNCDEF(numhead_0d)
-
-void ImpSvNumMultipleReadHeader::StartEntry()
-{
- sal_uLong nPos = rStream.Tell();
- sal_uInt32 nEntrySize;
- (*pMemStream).ReadUInt32( nEntrySize );
-
- nEntryEnd = nPos + nEntrySize;
-}
-
-//#pragma SEG_FUNCDEF(numhead_09)
-
-sal_uLong ImpSvNumMultipleReadHeader::BytesLeft() const
-{
- sal_uLong nReadEnd = rStream.Tell();
- if (nReadEnd <= nEntryEnd)
- return nEntryEnd-nReadEnd;
-
- OSL_FAIL("Error in ImpSvNumMultipleReadHeader::BytesLeft");
- return 0;
-}
-
-
-//#pragma SEG_FUNCDEF(numhead_0a)
-
-ImpSvNumMultipleWriteHeader::ImpSvNumMultipleWriteHeader(SvStream& rNewStream,
- sal_uLong nDefault) :
- rStream( rNewStream ),
- aMemStream( 4096, 4096 )
-{
- nDataSize = nDefault;
- rStream.WriteUInt32( nDataSize );
-
- nDataPos = rStream.Tell();
- nEntryStart = nDataPos;
-}
-
-//#pragma SEG_FUNCDEF(numhead_0b)
-
-ImpSvNumMultipleWriteHeader::~ImpSvNumMultipleWriteHeader()
-{
- sal_uLong nDataEnd = rStream.Tell();
-
- rStream.WriteUInt16( SV_NUMID_SIZES );
- rStream.WriteUInt32( aMemStream.Tell() );
- rStream.Write( aMemStream.GetData(), aMemStream.Tell() );
-
- if ( nDataEnd - nDataPos != nDataSize ) // Hit Default?
- {
- nDataSize = nDataEnd - nDataPos;
- sal_uLong nPos = rStream.Tell();
- rStream.Seek(nDataPos-sizeof(sal_uInt32));
- rStream.WriteUInt32( nDataSize ); // Add size at the start
- rStream.Seek(nPos);
- }
-}
-
-//#pragma SEG_FUNCDEF(numhead_0c)
-
-void ImpSvNumMultipleWriteHeader::EndEntry()
-{
- sal_uLong nPos = rStream.Tell();
- aMemStream.WriteUInt32( nPos - nEntryStart );
-}
-
-//#pragma SEG_FUNCDEF(numhead_0e)
-
-void ImpSvNumMultipleWriteHeader::StartEntry()
-{
- sal_uLong nPos = rStream.Tell();
- nEntryStart = nPos;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/numbers/numhead.hxx b/svl/source/numbers/numhead.hxx
deleted file mode 100644
index 86e7535f760e..000000000000
--- a/svl/source/numbers/numhead.hxx
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_SVL_SOURCE_NUMBERS_NUMHEAD_HXX
-#define INCLUDED_SVL_SOURCE_NUMBERS_NUMHEAD_HXX
-
-#include <tools/stream.hxx>
-
-// This header contains size measures for various objects
-
-class ImpSvNumMultipleReadHeader
-{
-private:
- SvStream& rStream;
- char* pBuf;
- SvMemoryStream* pMemStream;
- sal_uLong nEndPos;
- sal_uLong nEntryEnd;
-
-public:
- ImpSvNumMultipleReadHeader(SvStream& rNewStream);
- ~ImpSvNumMultipleReadHeader();
-
- void StartEntry();
- void EndEntry();
- sal_uLong BytesLeft() const;
-};
-
-class ImpSvNumMultipleWriteHeader
-{
-private:
- SvStream& rStream;
- SvMemoryStream aMemStream;
- sal_uLong nDataPos;
- sal_uInt32 nDataSize;
- sal_uLong nEntryStart;
-
-public:
- ImpSvNumMultipleWriteHeader(SvStream& rNewStream, sal_uLong nDefault = 0);
- ~ImpSvNumMultipleWriteHeader();
-
- void StartEntry();
- void EndEntry();
-};
-
-#endif
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index fba025a8e1fc..db638ab11857 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -36,7 +36,6 @@
#include "zforscan.hxx"
#include "zforfind.hxx"
#include <svl/zformat.hxx>
-#include "numhead.hxx"
#include <unotools/syslocaleoptions.hxx>
#include <unotools/digitgroupingiterator.hxx>
@@ -198,7 +197,6 @@ SvNumberFormatter::SvNumberFormatter( const Reference< XComponentContext >& rxCo
ImpConstruct( eLang );
}
-
SvNumberFormatter::~SvNumberFormatter()
{
{
@@ -673,150 +671,12 @@ sal_uInt32 SvNumberFormatter::GetIndexPuttingAndConverting( OUString & rString,
return nKey;
}
-
void SvNumberFormatter::DeleteEntry(sal_uInt32 nKey)
{
delete aFTable[nKey];
aFTable.erase(nKey);
}
-bool SvNumberFormatter::Load( SvStream& rStream )
-{
- LanguageType eSysLang = SvtSysLocale().GetLanguageTag().getLanguageType();
- boost::scoped_ptr<SvNumberFormatter> pConverter;
-
- ImpSvNumMultipleReadHeader aHdr( rStream );
- sal_uInt16 nVersion;
- rStream.ReadUInt16( nVersion );
- SvNumberformat* pEntry;
- sal_uInt32 nPos;
- sal_uInt16 nSysOnStore, eLge, eDummy; // Dummy for compatible format
- rStream.ReadUInt16( nSysOnStore ).ReadUInt16( eLge ); // system language from document
-
- SAL_WARN_IF( nVersion < SV_NUMBERFORMATTER_VERSION_CALENDAR, "svl.numbers", "SvNumberFormatter::Load: where does this unsupported old data come from?!?");
-
- LanguageType eSaveSysLang = (LanguageType) nSysOnStore;
- LanguageType eLnge = (LanguageType) eLge;
- ImpChangeSysCL( eLnge, true );
-
- rStream.ReadUInt32( nPos );
- while (nPos != NUMBERFORMAT_ENTRY_NOT_FOUND)
- {
- rStream.ReadUInt16( eDummy ).ReadUInt16( eLge );
- eLnge = (LanguageType) eLge;
- ImpGenerateCL( eLnge, true ); // create new standard formats if necessary
-
- sal_uInt32 nOffset = nPos % SV_COUNTRY_LANGUAGE_OFFSET; // relativIndex
- bool bUserDefined = (nOffset > SV_MAX_ANZ_STANDARD_FORMATE);
-
- pEntry = new SvNumberformat(*pFormatScanner, eLnge);
- pEntry->Load( rStream, aHdr, NULL, *pStringScanner );
- if ( !bUserDefined )
- {
- bUserDefined = (pEntry->GetNewStandardDefined() > SV_NUMBERFORMATTER_VERSION);
- }
- if ( bUserDefined )
- {
- LanguageType eLoadSysLang = (eLnge == LANGUAGE_SYSTEM ? eSysLang : eSaveSysLang);
- if ( eSaveSysLang != eLoadSysLang )
- {
- // different SYSTEM locale
- if ( !pConverter )
- {
- pConverter.reset(new SvNumberFormatter( m_xContext, eSysLang ));
- }
- pEntry->ConvertLanguage( *pConverter, eSaveSysLang, eLoadSysLang, true );
- }
- }
- if ( nOffset == 0 ) // Standard/General format
- {
- SvNumberformat* pEnt = GetFormatEntry(nPos);
- if (pEnt)
- {
- pEnt->SetLastInsertKey(pEntry->GetLastInsertKey());
- }
- }
- if (!aFTable.insert(make_pair( nPos, pEntry)).second)
- {
- SAL_WARN( "svl.numbers", "SvNumberFormatter::Load: dup position");
- delete pEntry;
- }
- rStream.ReadUInt32( nPos );
- }
-
- // as of SV_NUMBERFORMATTER_VERSION_YEAR2000
- if ( nVersion >= SV_NUMBERFORMATTER_VERSION_YEAR2000 )
- {
- aHdr.StartEntry();
- if ( aHdr.BytesLeft() >= sizeof(sal_uInt16) )
- {
- sal_uInt16 nY2k;
- rStream.ReadUInt16( nY2k );
- if ( nVersion < SV_NUMBERFORMATTER_VERSION_TWODIGITYEAR && nY2k < 100 )
- {
- nY2k += 1901; // was before src513e: 29, now: 1930
- }
- SetYear2000( nY2k );
- }
- aHdr.EndEntry();
- }
-
- pConverter.reset();
-
- // generate additional i18n standard formats for all used locales
- LanguageType eOldLanguage = ActLnge;
- NumberFormatCodeWrapper aNumberFormatCode( m_xContext,
- GetLanguageTag().getLocale() );
- std::vector<sal_uInt16> aList;
- GetUsedLanguages( aList );
- for ( std::vector<sal_uInt16>::const_iterator it(aList.begin()); it != aList.end(); ++it )
- {
- LanguageType eLang = *it;
- ChangeIntl( eLang );
- sal_uInt32 CLOffset = ImpGetCLOffset( eLang );
- ImpGenerateAdditionalFormats( CLOffset, aNumberFormatCode, true );
- }
- ChangeIntl( eOldLanguage );
-
- return rStream.GetError() ? false : true;
-}
-
-bool SvNumberFormatter::Save( SvStream& rStream ) const
-{
- ImpSvNumMultipleWriteHeader aHdr( rStream );
- // As of 364i we store what SYSTEM locale really was, before it was hard
- // coded LANGUAGE_SYSTEM.
- rStream.WriteUInt16( SV_NUMBERFORMATTER_VERSION );
- rStream.WriteUInt16( SvtSysLocale().GetLanguageTag().getLanguageType() ).WriteUInt16( IniLnge );
-
- const SvNumberFormatTable* pTable = &aFTable;
- SvNumberFormatTable::const_iterator it = pTable->begin();
- while (it != pTable->end())
- {
- SvNumberformat* pEntry = it->second;
- // Stored are all marked user defined formats and for each active
- // (selected) locale the Standard/General format and
- // NewStandardDefined.
- if ( pEntry->GetUsed() || (pEntry->GetType() & NUMBERFORMAT_DEFINED) ||
- pEntry->GetNewStandardDefined() || (it->first % SV_COUNTRY_LANGUAGE_OFFSET == 0) )
- {
- rStream.WriteUInt32( it->first )
- .WriteUInt16( LANGUAGE_SYSTEM )
- .WriteUInt16( pEntry->GetLanguage() );
- pEntry->Save(rStream, aHdr);
- }
- ++it;
- }
- rStream.WriteUInt32( NUMBERFORMAT_ENTRY_NOT_FOUND ); // end marker
-
- // as of SV_NUMBERFORMATTER_VERSION_YEAR2000
- aHdr.StartEntry();
- rStream.WriteUInt16( GetYear2000() );
- aHdr.EndEntry();
-
- return rStream.GetError() ? false : true;
-}
-
void SvNumberFormatter::GetUsedLanguages( std::vector<sal_uInt16>& rList )
{
rList.clear();
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index aa877b8acaec..9da644d656e7 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -41,7 +41,6 @@
#include "zforfind.hxx"
#include <svl/zforlist.hxx>
-#include "numhead.hxx"
#include <unotools/digitgroupingiterator.hxx>
#include <svl/nfsymbol.hxx>
@@ -146,52 +145,6 @@ void ImpSvNumberformatInfo::Copy( const ImpSvNumberformatInfo& rNumFor, sal_uInt
nCntExp = rNumFor.nCntExp;
}
-void ImpSvNumberformatInfo::Save(SvStream& rStream, sal_uInt16 nAnz) const
-{
- for (sal_uInt16 i = 0; i < nAnz; i++)
- {
- rStream.WriteUniOrByteString( sStrArray[i], rStream.GetStreamCharSet() );
- short nType = nTypeArray[i];
- switch ( nType )
- {
- // The fight with versions before SV_NUMBERFORMATTER_VERSION_NEW_CURR
- case NF_SYMBOLTYPE_CURRENCY :
- rStream.WriteInt16( short( NF_SYMBOLTYPE_STRING ) );
- break;
- case NF_SYMBOLTYPE_CURRDEL :
- case NF_SYMBOLTYPE_CURREXT :
- rStream.WriteInt16( short(0) ); // will be ignored (hopefully ...)
- break;
- default:
- if ( nType > NF_KEY_LASTKEYWORD_SO5 )
- {
- rStream.WriteInt16( short( NF_SYMBOLTYPE_STRING ) ); // all new keywords are string
- }
- else
- {
- rStream.WriteInt16( nType );
- }
- }
-
- }
- rStream.WriteInt16( eScannedType ).WriteUChar( bThousand ).WriteUInt16( nThousand )
- .WriteUInt16( nCntPre ).WriteUInt16( nCntPost ).WriteUInt16( nCntExp );
-}
-
-void ImpSvNumberformatInfo::Load(SvStream& rStream, sal_uInt16 nAnz)
-{
- for (sal_uInt16 i = 0; i < nAnz; ++i)
- {
- sStrArray[i] = SvNumberformat::LoadString( rStream );
- rStream.ReadInt16( nTypeArray[i] );
- }
- bool bStreamThousand;
- rStream.ReadInt16( eScannedType ).ReadCharAsBool( bStreamThousand ).ReadUInt16( nThousand )
- .ReadUInt16( nCntPre ).ReadUInt16( nCntPost ).ReadUInt16( nCntExp );
- bThousand = bStreamThousand;
-}
-
-
// static
sal_uInt8 SvNumberNatNum::MapDBNumToNatNum( sal_uInt8 nDBNum, LanguageType eLang, bool bDate )
{
@@ -442,25 +395,6 @@ void ImpSvNumFor::Copy( const ImpSvNumFor& rNumFor, ImpSvNumberformatScan* pSc )
aNatNum = rNumFor.aNatNum;
}
-void ImpSvNumFor::Save(SvStream& rStream) const
-{
- rStream.WriteUInt16( nAnzStrings );
- aI.Save(rStream, nAnzStrings);
- rStream.WriteUniOrByteString( sColorName, rStream.GetStreamCharSet() );
-}
-
-void ImpSvNumFor::Load(SvStream& rStream, ImpSvNumberformatScan& rSc,
- OUString& rLoadedColorName )
-{
- sal_uInt16 nAnz;
- rStream.ReadUInt16( nAnz ); //! Not nAnzStrings right away due to Enlarge
- Enlarge( nAnz );
- aI.Load( rStream, nAnz );
- sColorName = rStream.ReadUniOrByteString( rStream.GetStreamCharSet() );
- rLoadedColorName = sColorName;
- pColor = rSc.GetColor(sColorName);
-}
-
bool ImpSvNumFor::HasNewCurrency() const
{
for ( sal_uInt16 j=0; j<nAnzStrings; j++ )
@@ -496,53 +430,6 @@ bool ImpSvNumFor::GetNewCurrencySymbol( OUString& rSymbol,
return false;
}
-void ImpSvNumFor::SaveNewCurrencyMap( SvStream& rStream ) const
-{
- sal_uInt16 j;
- sal_uInt16 nCnt = 0;
- for ( j=0; j<nAnzStrings; j++ )
- {
- switch ( aI.nTypeArray[j] )
- {
- case NF_SYMBOLTYPE_CURRENCY :
- case NF_SYMBOLTYPE_CURRDEL :
- case NF_SYMBOLTYPE_CURREXT :
- nCnt++;
- break;
- }
- }
- rStream.WriteUInt16( nCnt );
- for ( j=0; j<nAnzStrings; j++ )
- {
- switch ( aI.nTypeArray[j] )
- {
- case NF_SYMBOLTYPE_CURRENCY :
- case NF_SYMBOLTYPE_CURRDEL :
- case NF_SYMBOLTYPE_CURREXT :
- rStream.WriteUInt16( j ).WriteInt16( aI.nTypeArray[j] );
- break;
- }
- }
-}
-
-void ImpSvNumFor::LoadNewCurrencyMap( SvStream& rStream )
-{
- sal_uInt16 nCnt;
- rStream.ReadUInt16(nCnt);
- if (!nCnt)
- return;
- for (sal_uInt16 j=0; j < nCnt; ++j)
- {
- sal_uInt16 nPos;
- short nType;
- rStream.ReadUInt16( nPos ).ReadInt16( nType );
- if ( nPos < nAnzStrings )
- {
- aI.nTypeArray[nPos] = nType;
- }
- }
-}
-
/**
* SvNumberformat
*/
@@ -1533,14 +1420,14 @@ short SvNumberformat::ImpNextSymbol(OUStringBuffer& rString,
eState = SsGetPrefix;
}
else
- { // currency as of SV_NUMBERFORMATTER_VERSION_NEW_CURR
+ { // currency
eSymbolType = BRACKET_SYMBOLTYPE_FORMAT;
eState = SsGetString;
}
sBuffSymbol.append(cToken);
break;
case '~' :
- // calendarID as of SV_NUMBERFORMATTER_VERSION_CALENDAR
+ // calendarID
eSymbolType = BRACKET_SYMBOLTYPE_FORMAT;
sBuffSymbol.append(cToken);
eState = SsGetString;
@@ -1708,189 +1595,6 @@ short SvNumberformat::ImpNextSymbol(OUStringBuffer& rString,
return eSymbolType;
}
-NfHackConversion SvNumberformat::Load( SvStream& rStream,
- ImpSvNumMultipleReadHeader& rHdr,
- SvNumberFormatter* pHackConverter,
- ImpSvNumberInputScan& rISc )
-{
- rHdr.StartEntry();
- sal_uInt16 nOp1, nOp2;
- sFormatstring = SvNumberformat::LoadString( rStream );
- bool bStreamStandard, bStreamUsed;
- rStream.ReadInt16( eType ).ReadDouble( fLimit1 ).ReadDouble( fLimit2 )
- .ReadUInt16( nOp1 ).ReadUInt16( nOp2 ).ReadCharAsBool( bStreamStandard ).ReadCharAsBool( bStreamUsed );
- bStandard = bStreamStandard;
- bIsUsed = bStreamUsed;
- NfHackConversion eHackConversion = NF_CONVERT_NONE;
- bool bOldConvert = false;
- LanguageType eOldTmpLang = 0;
- LanguageType eOldNewLang = 0;
- if ( pHackConverter )
- {
- // Are only needed here
- bOldConvert = rScan.GetConvertMode();
- eOldTmpLang = rScan.GetTmpLnge();
- eOldNewLang = rScan.GetNewLnge();
- }
- OUString aLoadedColorName;
- for (sal_uInt16 i = 0; i < 4; i++)
- {
- NumFor[i].Load( rStream, rScan, aLoadedColorName );
- if ( pHackConverter && eHackConversion == NF_CONVERT_NONE )
- {
- // FIXME: HACK!
- // Unfortunately we didn't save what SYSTEM on Save really was :-/
- // After all we save FARBE or COLOR for an Entry ...
- // When translating from System-German FARBE to System-xxx COLOR and vice versa,
- // we assume that onSave only has GERMAN and ENGLISH KeyWords in ImpSvNumberformatScan
- if ( !aLoadedColorName.isEmpty() &&
- !NumFor[i].GetColor() &&
- aLoadedColorName != rScan.GetColorString() )
- {
- if ( rScan.GetColorString() == "FARBE" )
- { // English -> German
- eHackConversion = NF_CONVERT_ENGLISH_GERMAN;
- rScan.GetNumberformatter()->ChangeIntl( LANGUAGE_ENGLISH_US );
- rScan.SetConvertMode( LANGUAGE_ENGLISH_US, LANGUAGE_GERMAN );
- }
- else
- { // German -> English
- eHackConversion = NF_CONVERT_GERMAN_ENGLISH;
- rScan.GetNumberformatter()->ChangeIntl( LANGUAGE_GERMAN );
- rScan.SetConvertMode( LANGUAGE_GERMAN, LANGUAGE_ENGLISH_US );
- }
- OUString aColorName = NumFor[i].GetColorName();
- const Color* pColor = rScan.GetColor( aColorName );
- if ( !pColor && aLoadedColorName == aColorName )
- {
- eHackConversion = NF_CONVERT_NONE;
- }
- rScan.GetNumberformatter()->ChangeIntl( LANGUAGE_SYSTEM );
- rScan.SetConvertMode( eOldTmpLang, eOldNewLang );
- rScan.SetConvertMode( bOldConvert );
- }
- }
- }
- eOp1 = (SvNumberformatLimitOps) nOp1;
- eOp2 = (SvNumberformatLimitOps) nOp2;
- OUString aComment; // Will be set to the correct value after the NewCurrency troubles
- if ( rHdr.BytesLeft() )
- {
- // As of SV_NUMBERFORMATTER_VERSION_NEWSTANDARD
- aComment = SvNumberformat::LoadString( rStream );
- rStream.ReadUInt16( nNewStandardDefined );
- }
-
- sal_Int32 nNewCurrencyEnd = -1;
- bool bNewCurrencyComment = ( aComment.getLength() > 1 && aComment[0] == cNewCurrencyMagic &&
- (nNewCurrencyEnd = aComment.indexOf( cNewCurrencyMagic, 1 )) >= 0 );
- bool bNewCurrencyLoaded = false;
- bool bNewCurrency = false;
-
- bool bGoOn = true;
- while ( rHdr.BytesLeft() && bGoOn )
- {
- // as of SV_NUMBERFORMATTER_VERSION_NEW_CURR
- sal_uInt16 nId;
- unsigned char bStreamCurr;
- rStream.ReadUInt16( nId );
- switch ( nId )
- {
- case nNewCurrencyVersionId :
- bNewCurrencyLoaded = true;
- rStream.ReadUChar( bStreamCurr );
- bNewCurrency = bStreamCurr;
- if ( bNewCurrency )
- {
- for ( sal_uInt16 j=0; j<4; j++ )
- {
- NumFor[j].LoadNewCurrencyMap( rStream );
- }
- }
- break;
- case nNewStandardFlagVersionId :
- rStream.ReadCharAsBool( bStreamStandard ); // the real standard flag
- bStandard = bStreamStandard;
- break;
- default:
- SAL_WARN( "svl.numbers", "SvNumberformat::Load: unknown header bytes left nId" );
- bGoOn = false; // stop reading unknown stream left over of newer versions
- // Would be nice to have multiple read/write headers instead
- // but old versions wouldn't know it, TLOT.
- }
- }
- rHdr.EndEntry();
-
- if ( bNewCurrencyLoaded )
- {
- if ( bNewCurrency && bNewCurrencyComment )
- { // Recover original format string and comment
- sFormatstring = aComment.copy( 1, nNewCurrencyEnd-1 );
- if(nNewCurrencyEnd + 1 < aComment.getLength())
- {
- aComment = aComment.copy(nNewCurrencyEnd + 1 );
- }
- else
- {
- aComment = "";
- }
- }
- }
- else if ( bNewCurrencyComment )
- {
- // New, but saved with version before SV_NUMBERFORMATTER_VERSION_NEW_CURR
- // Recover original format string and comment
- sFormatstring = aComment.copy( 1, nNewCurrencyEnd - 1 );
- if(nNewCurrencyEnd + 1 < aComment.getLength())
- {
- aComment = aComment.copy(nNewCurrencyEnd + 1 );
- }
- else
- {
- aComment = "";
- }
- // Remember states
- short nDefined = ( eType & NUMBERFORMAT_DEFINED );
- sal_uInt16 nNewStandard = nNewStandardDefined;
-
- // Parse new ones etc.
- OUString aStr( sFormatstring );
- sal_Int32 nCheckPos = 0;
- boost::scoped_ptr<SvNumberformat> pFormat(new SvNumberformat( aStr, &rScan, &rISc,
- nCheckPos, maLocale.meLanguage, bStandard ));
- DBG_ASSERT( !nCheckPos, "SvNumberformat::Load: NewCurrencyRescan nCheckPos" );
- ImpCopyNumberformat( *pFormat );
- pFormat.reset();
-
- // Recover states
- eType |= nDefined;
- if ( nNewStandard )
- {
- SetNewStandardDefined( nNewStandard );
- }
- }
- SetComment( aComment );
-
- if ( eHackConversion != NF_CONVERT_NONE )
- {
- //! and we continue with the HACK!
- switch ( eHackConversion )
- {
- case NF_CONVERT_ENGLISH_GERMAN :
- ConvertLanguage( *pHackConverter,
- LANGUAGE_ENGLISH_US, LANGUAGE_GERMAN, true );
- break;
- case NF_CONVERT_GERMAN_ENGLISH :
- ConvertLanguage( *pHackConverter,
- LANGUAGE_GERMAN, LANGUAGE_ENGLISH_US, true );
- break;
- default:
- SAL_WARN( "svl.numbers", "SvNumberformat::Load: eHackConversion unknown" );
- }
- }
- return eHackConversion;
-}
-
void SvNumberformat::ConvertLanguage( SvNumberFormatter& rConverter,
LanguageType eConvertFrom,
LanguageType eConvertTo, bool bSystem )
@@ -1929,92 +1633,6 @@ void SvNumberformat::ConvertLanguage( SvNumberFormatter& rConverter,
}
}
-// static
-OUString SvNumberformat::LoadString( SvStream& rStream )
-{
- rtl_TextEncoding eStream = rStream.GetStreamCharSet();
- OString aStr = read_uInt16_lenPrefixed_uInt8s_ToOString(rStream);
- sal_Char cStream = NfCurrencyEntry::GetEuroSymbol( eStream );
- if (aStr.indexOf(cStream) < 0)
- {
- // simple conversion to unicode
- return OStringToOUString(aStr, eStream);
- }
- sal_Unicode cSource = OUString(&cStream, 1, eStream).toChar();
- sal_Unicode cTarget = NfCurrencyEntry::GetEuroSymbol();
- OUStringBuffer aBuf(OStringToOUString(aStr, eStream));
- aBuf.replace(cSource, cTarget);
-
- return aBuf.makeStringAndClear();
-}
-
-void SvNumberformat::Save( SvStream& rStream, ImpSvNumMultipleWriteHeader& rHdr ) const
-{
- OUString aFormatstring( sFormatstring );
- OUStringBuffer aComment( sComment.getLength() + sFormatstring.getLength() + 2 );
-
- bool bNewCurrency = HasNewCurrency();
- if ( bNewCurrency )
- {
- // Save SV_NUMBERFORMATTER_VERSION_NEW_CURR in comment
- aComment.insert( 0, cNewCurrencyMagic );
- aComment.insert( 0, cNewCurrencyMagic );
- aComment.insert( 1, aFormatstring );
- Build50Formatstring( aFormatstring ); // Generate old format string
- }
-
- // old SO5 versions do behave strange (no output) if standard flag is set
- // on formats not prepared for it (not having the following exact types)
- bool bOldStandard = bStandard;
- if ( bOldStandard )
- {
- switch ( eType )
- {
- case NUMBERFORMAT_NUMBER :
- case NUMBERFORMAT_DATE :
- case NUMBERFORMAT_TIME :
- case NUMBERFORMAT_DATETIME :
- case NUMBERFORMAT_PERCENT :
- case NUMBERFORMAT_SCIENTIFIC :
- // ok to save
- break;
- default:
- bOldStandard = false;
- }
- }
-
- rHdr.StartEntry();
- rStream.WriteUniOrByteString( aFormatstring, rStream.GetStreamCharSet() );
- rStream.WriteInt16( eType ).WriteDouble( fLimit1 ).WriteDouble( fLimit2 ).WriteUInt16( eOp1 ).WriteUInt16( eOp2 )
- .WriteUChar( bOldStandard ).WriteUChar( bIsUsed );
- for (sal_uInt16 i = 0; i < 4; i++)
- {
- NumFor[i].Save(rStream);
- }
- // As of SV_NUMBERFORMATTER_VERSION_NEWSTANDARD
- rStream.WriteUniOrByteString( aComment.makeStringAndClear(), rStream.GetStreamCharSet() );
- rStream.WriteUInt16( nNewStandardDefined );
- // As of SV_NUMBERFORMATTER_VERSION_NEW_CURR
- rStream.WriteUInt16( nNewCurrencyVersionId );
- rStream.WriteUChar( bNewCurrency );
- if ( bNewCurrency )
- {
- for ( sal_uInt16 j=0; j<4; j++ )
- {
- NumFor[j].SaveNewCurrencyMap( rStream );
- }
- }
-
- // the real standard flag to load with versions >638 if different
- if ( bStandard != bOldStandard )
- {
- rStream.WriteUInt16( nNewStandardFlagVersionId );
- rStream.WriteUChar( bStandard );
- }
-
- rHdr.EndEntry();
-}
-
bool SvNumberformat::HasNewCurrency() const
{
for ( sal_uInt16 j=0; j<4; j++ )
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index 813dededb663..daf30c1f67f0 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -1241,14 +1241,14 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
if ( i < nAnzStrings-1 &&
nTypeArray[i+1] == NF_SYMBOLTYPE_STRING &&
sStrArray[i+1][0] == '$' )
- { // as of SV_NUMBERFORMATTER_VERSION_NEW_CURR
+ {
eNewType = NUMBERFORMAT_CURRENCY;
bMatchBracket = true;
}
else if ( i < nAnzStrings-1 &&
nTypeArray[i+1] == NF_SYMBOLTYPE_STRING &&
sStrArray[i+1][0] == '~' )
- { // as of SV_NUMBERFORMATTER_VERSION_CALENDAR
+ {
eNewType = NUMBERFORMAT_DATE;
bMatchBracket = true;
}
@@ -1482,7 +1482,6 @@ int ImpSvNumberformatScan::FinalScanGetCalendar( sal_Int32& nPos, sal_uInt16& i,
sStrArray[i+1][0] == '~' )
{
// [~calendarID]
- // as of SV_NUMBERFORMATTER_VERSION_CALENDAR
nPos = nPos + sStrArray[i].getLength(); // [
nTypeArray[i] = NF_SYMBOLTYPE_CALDEL;
nPos = nPos + sStrArray[++i].getLength(); // ~
@@ -2042,7 +2041,6 @@ sal_Int32 ImpSvNumberformatScan::FinalScan( OUString& rString )
sStrArray[i+1][0] == '$' )
{
// [$DM-xxx]
- // As of SV_NUMBERFORMATTER_VERSION_NEW_CURR
nPos = nPos + sStrArray[i].getLength(); // [
nTypeArray[i] = NF_SYMBOLTYPE_CURRDEL;
nPos = nPos + sStrArray[++i].getLength(); // $