GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / svl / source / numbers / numhead.cxx
blob2d318461cc797296dccaaec78c58048425ea4604
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 <tools/debug.hxx>
22 #include "numhead.hxx"
24 // ID's for files:
25 #define SV_NUMID_SIZES 0x4200
27 //#pragma SEG_FUNCDEF(numhead_06)
29 //! Synchronous with Skip()
30 ImpSvNumMultipleReadHeader::ImpSvNumMultipleReadHeader(SvStream& rNewStream) :
31 rStream( rNewStream )
33 sal_uInt32 nDataSize;
34 rStream >> nDataSize;
35 sal_uLong nDataPos = rStream.Tell();
36 nEntryEnd = nDataPos;
38 rStream.SeekRel(nDataSize);
39 sal_uInt16 nID;
40 rStream >> nID;
41 if (nID != SV_NUMID_SIZES)
43 OSL_FAIL("SV_NUMID_SIZES not found");
45 sal_uInt32 nSizeTableLen;
46 rStream >> nSizeTableLen;
47 pBuf = new char[nSizeTableLen];
48 rStream.Read( pBuf, nSizeTableLen );
49 pMemStream = new SvMemoryStream( pBuf, nSizeTableLen, STREAM_READ );
51 nEndPos = rStream.Tell();
52 rStream.Seek( nDataPos );
55 //#pragma SEG_FUNCDEF(numhead_07)
57 ImpSvNumMultipleReadHeader::~ImpSvNumMultipleReadHeader()
59 DBG_ASSERT( pMemStream->Tell() == pMemStream->GetEndOfData(),
60 "Sizes not completely read" );
61 delete pMemStream;
62 delete [] pBuf;
64 rStream.Seek(nEndPos);
67 //#pragma SEG_FUNCDEF(numhead_08)
69 void ImpSvNumMultipleReadHeader::EndEntry()
71 sal_uLong nPos = rStream.Tell();
72 DBG_ASSERT( nPos <= nEntryEnd, "Read too much" );
73 if ( nPos != nEntryEnd )
74 rStream.Seek( nEntryEnd ); // Skip the rest
77 //#pragma SEG_FUNCDEF(numhead_0d)
79 void ImpSvNumMultipleReadHeader::StartEntry()
81 sal_uLong nPos = rStream.Tell();
82 sal_uInt32 nEntrySize;
83 (*pMemStream) >> nEntrySize;
85 nEntryEnd = nPos + nEntrySize;
88 //#pragma SEG_FUNCDEF(numhead_09)
90 sal_uLong ImpSvNumMultipleReadHeader::BytesLeft() const
92 sal_uLong nReadEnd = rStream.Tell();
93 if (nReadEnd <= nEntryEnd)
94 return nEntryEnd-nReadEnd;
96 OSL_FAIL("Error in ImpSvNumMultipleReadHeader::BytesLeft");
97 return 0;
101 //#pragma SEG_FUNCDEF(numhead_0a)
103 ImpSvNumMultipleWriteHeader::ImpSvNumMultipleWriteHeader(SvStream& rNewStream,
104 sal_uLong nDefault) :
105 rStream( rNewStream ),
106 aMemStream( 4096, 4096 )
108 nDataSize = nDefault;
109 rStream << nDataSize;
111 nDataPos = rStream.Tell();
112 nEntryStart = nDataPos;
115 //#pragma SEG_FUNCDEF(numhead_0b)
117 ImpSvNumMultipleWriteHeader::~ImpSvNumMultipleWriteHeader()
119 sal_uLong nDataEnd = rStream.Tell();
121 rStream << (sal_uInt16) SV_NUMID_SIZES;
122 rStream << static_cast<sal_uInt32>(aMemStream.Tell());
123 rStream.Write( aMemStream.GetData(), aMemStream.Tell() );
125 if ( nDataEnd - nDataPos != nDataSize ) // Hit Default?
127 nDataSize = nDataEnd - nDataPos;
128 sal_uLong nPos = rStream.Tell();
129 rStream.Seek(nDataPos-sizeof(sal_uInt32));
130 rStream << nDataSize; // Add size at the start
131 rStream.Seek(nPos);
135 //#pragma SEG_FUNCDEF(numhead_0c)
137 void ImpSvNumMultipleWriteHeader::EndEntry()
139 sal_uLong nPos = rStream.Tell();
140 aMemStream << static_cast<sal_uInt32>(nPos - nEntryStart);
143 //#pragma SEG_FUNCDEF(numhead_0e)
145 void ImpSvNumMultipleWriteHeader::StartEntry()
147 sal_uLong nPos = rStream.Tell();
148 nEntryStart = nPos;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */