1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
25 #define SV_NUMID_SIZES 0x4200
27 //#pragma SEG_FUNCDEF(numhead_06)
29 //! mit Skip() synchron
30 ImpSvNumMultipleReadHeader::ImpSvNumMultipleReadHeader(SvStream
& rNewStream
) :
35 sal_uLong nDataPos
= rStream
.Tell();
38 rStream
.SeekRel(nDataSize
);
41 if (nID
!= SV_NUMID_SIZES
)
43 OSL_FAIL("SV_NUMID_SIZES nicht gefunden");
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 nicht vollstaendig gelesen" );
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
, "zuviel gelesen" );
73 if ( nPos
!= nEntryEnd
)
74 rStream
.Seek( nEntryEnd
); // Rest ueberspringen
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("Fehler bei ImpSvNumMultipleReadHeader::BytesLeft");
100 // -----------------------------------------------------------------------
102 //#pragma SEG_FUNCDEF(numhead_0a)
104 ImpSvNumMultipleWriteHeader::ImpSvNumMultipleWriteHeader(SvStream
& rNewStream
,
105 sal_uLong nDefault
) :
106 rStream( rNewStream
),
107 aMemStream( 4096, 4096 )
109 nDataSize
= nDefault
;
110 rStream
<< nDataSize
;
112 nDataPos
= rStream
.Tell();
113 nEntryStart
= nDataPos
;
116 //#pragma SEG_FUNCDEF(numhead_0b)
118 ImpSvNumMultipleWriteHeader::~ImpSvNumMultipleWriteHeader()
120 sal_uLong nDataEnd
= rStream
.Tell();
122 rStream
<< (sal_uInt16
) SV_NUMID_SIZES
;
123 rStream
<< static_cast<sal_uInt32
>(aMemStream
.Tell());
124 rStream
.Write( aMemStream
.GetData(), aMemStream
.Tell() );
126 if ( nDataEnd
- nDataPos
!= nDataSize
) // Default getroffen?
128 nDataSize
= nDataEnd
- nDataPos
;
129 sal_uLong nPos
= rStream
.Tell();
130 rStream
.Seek(nDataPos
-sizeof(sal_uInt32
));
131 rStream
<< nDataSize
; // Groesse am Anfang eintragen
136 //#pragma SEG_FUNCDEF(numhead_0c)
138 void ImpSvNumMultipleWriteHeader::EndEntry()
140 sal_uLong nPos
= rStream
.Tell();
141 aMemStream
<< static_cast<sal_uInt32
>(nPos
- nEntryStart
);
144 //#pragma SEG_FUNCDEF(numhead_0e)
146 void ImpSvNumMultipleWriteHeader::StartEntry()
148 sal_uLong nPos
= rStream
.Tell();
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */