Kaydet (Commit) 48a4d615 authored tarafından Caolán McNamara's avatar Caolán McNamara

If XPersistObject support is dropped, all this unsupported old data can go

Change-Id: I7000df307920b1b04b81cc4c436009cf6b6548e0
Reviewed-on: https://gerrit.libreoffice.org/12282Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 9e05e454
......@@ -21,17 +21,10 @@
#define INCLUDED_SVL_NFVERSI_HXX
// file IDs
#define SV_NUMBERFORMATTER_VERSION_SYSTORE 0x0004
#define SV_NUMBERFORMATTER_VERSION_KEYWORDS 0x0005
#define SV_NUMBERFORMATTER_VERSION_NEWSTANDARD 0x0006
#define SV_NUMBERFORMATTER_VERSION_NF_TIME_HH_MMSS00 0x0007
#define SV_NUMBERFORMATTER_VERSION_NF_DATE_WW 0x0008
#define SV_NUMBERFORMATTER_VERSION_NEW_CURR 0x0009
#define SV_NUMBERFORMATTER_VERSION_YEAR2000 0x000a
#define SV_NUMBERFORMATTER_VERSION_TWODIGITYEAR 0x000b
#define SV_NUMBERFORMATTER_VERSION_NF_DATETIME_SYS_DDMMYYYY_HHMMSS 0x000c
#define SV_NUMBERFORMATTER_VERSION_CALENDAR 0x000d
#define SV_NUMBERFORMATTER_VERSION_ADDITIONAL_I18N_FORMATS 0x000e
#define SV_NUMBERFORMATTER_VERSION_FIXED_FRACTION 0x000f
......
......@@ -37,7 +37,6 @@
#include <boost/ptr_container/ptr_vector.hpp>
class Date;
class SvStream;
class Color;
class CharClass;
class CalendarWrapper;
......@@ -518,11 +517,6 @@ public:
/// Whether format index nFIndex is of type text or not
bool IsTextFormat(sal_uInt32 nFIndex) const;
/// Load all formats from a stream
bool Load( SvStream& rStream );
/// Save all formats to a stream
bool Save( SvStream& rStream ) const;
/// Get additional info of a format index, e.g. for dialog box
void GetFormatSpecialInfo(sal_uInt32 nFormat, bool& bThousand, bool& IsRed,
sal_uInt16& nPrecision, sal_uInt16& nAnzLeading);
......
......@@ -29,13 +29,10 @@ namespace utl {
class DigitGroupingIterator;
}
class SvStream;
class Color;
class ImpSvNumberformatScan; // format code string scanner
class ImpSvNumberInputScan; // input string scanner
class ImpSvNumMultipleWriteHeader; // compatible file format
class ImpSvNumMultipleReadHeader; // compatible file format
class SvNumberFormatter;
enum SvNumberformatLimitOps
......@@ -69,8 +66,6 @@ struct ImpSvNumberformatInfo // Struct for FormatInfo
bool bThousand; // Has group (AKA thousand) separator
void Copy( const ImpSvNumberformatInfo& rNumFor, sal_uInt16 nAnz );
void Load(SvStream& rStream, sal_uInt16 nAnz);
void Save(SvStream& rStream, sal_uInt16 nAnz) const;
};
// NativeNumber, represent numbers using CJK or other digits if nNum>0,
......@@ -119,9 +114,6 @@ public:
~ImpSvNumFor();
void Enlarge(sal_uInt16 nAnz); // Init of arrays to the right size
void Load( SvStream& rStream, ImpSvNumberformatScan& rSc,
OUString& rLoadedColorName);
void Save( SvStream& rStream ) const;
// if pSc is set, it is used to get the Color pointer
void Copy( const ImpSvNumFor& rNumFor, ImpSvNumberformatScan* pSc );
......@@ -141,8 +133,6 @@ public:
// new SYMBOLTYPE_CURRENCY in subformat?
bool HasNewCurrency() const;
bool GetNewCurrencySymbol( OUString& rSymbol, OUString& rExtension ) const;
void SaveNewCurrencyMap( SvStream& rStream ) const;
void LoadNewCurrencyMap( SvStream& rStream );
// [NatNum1], [NatNum2], ...
void SetNatNumNum( sal_uInt8 nNum, bool bDBNum ) { aNatNum.SetNum( nNum, bDBNum ); }
......@@ -227,14 +217,6 @@ public:
bool IsStarFormatSupported() const { return bStarFlag; }
void SetStarFormatSupport( bool b ) { bStarFlag = b; }
NfHackConversion Load( SvStream& rStream, ImpSvNumMultipleReadHeader& rHdr,
SvNumberFormatter* pConverter, ImpSvNumberInputScan& rISc );
void Save( SvStream& rStream, ImpSvNumMultipleWriteHeader& rHdr ) const;
// Load a string which might contain an Euro symbol,
// in fact that could be any string used in number formats.
static OUString LoadString( SvStream& rStream );
/**
* Get output string from a numeric value that fits the number of
* characters specified.
......
......@@ -128,7 +128,6 @@ $(eval $(call gb_Library_add_exception_objects,svl,\
svl/source/notify/listener \
svl/source/notify/lstner \
svl/source/numbers/numfmuno \
svl/source/numbers/numhead \
svl/source/numbers/numuno \
svl/source/numbers/supservs \
svl/source/numbers/zforfind \
......
/* -*- 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: */
/* -*- 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: */
......@@ -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();
......
This diff is collapsed.
......@@ -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(); // $
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment