LibreOffice Module tools (master) 1
vcompat.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <tools/stream.hxx>
21#include <tools/vcompat.hxx>
22
24 : mrRStm(rStm)
25 , mnCompatPos(0)
26 , mnTotalSize(0)
27 , mnVersion(1)
28{
29 if (mrRStm.GetError())
30 return;
31
35}
36
38 : mrWStm(rStm)
39 , mnCompatPos(0)
40 , mnTotalSize(0)
41{
42 if (mrWStm.GetError())
43 return;
44
48 mrWStm.SeekRel(4);
49}
50
52{
53 const sal_uInt32 nReadSize = mrRStm.Tell() - mnCompatPos;
54
55 if (mnTotalSize > nReadSize)
56 mrRStm.SeekRel(mnTotalSize - nReadSize);
57}
58
60{
61 const sal_uInt32 nEndPos = mrWStm.Tell();
62
65 mrWStm.Seek(nEndPos);
66}
67
68/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 Tell() const
Definition: stream.hxx:271
SvStream & WriteUInt16(sal_uInt16 nUInt16)
Definition: stream.cxx:949
SvStream & WriteUInt32(sal_uInt32 nUInt32)
Definition: stream.cxx:950
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
Definition: stream.cxx:822
sal_uInt64 Seek(sal_uInt64 nPos)
Definition: stream.cxx:1262
sal_uInt64 SeekRel(sal_Int64 nPos)
Definition: stream.cxx:784
ErrCode GetError() const
Definition: stream.hxx:204
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
Definition: stream.cxx:821
SvStream & mrRStm
Definition: vcompat.hxx:34
sal_uInt32 mnCompatPos
Definition: vcompat.hxx:35
sal_uInt16 mnVersion
Definition: vcompat.hxx:37
VersionCompatRead(const VersionCompatRead &)=delete
sal_uInt32 mnTotalSize
Definition: vcompat.hxx:36
sal_uInt32 mnCompatPos
Definition: vcompat.hxx:52
VersionCompatWrite(const VersionCompatWrite &)=delete
sal_uInt32 mnTotalSize
Definition: vcompat.hxx:53
SvStream & mrWStm
Definition: vcompat.hxx:51
sal_Int16 nVersion