bump product version to 6.4.0.3
[LibreOffice.git] / sd / source / core / sdiocmpt.cxx
blob67de6a64d71deb4ad229f898fe6792dd04ebf1df
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 <sdiocmpt.hxx>
24 old_SdrDownCompat::old_SdrDownCompat(SvStream& rNewStream, StreamMode nNewMode)
25 : rStream(rNewStream),
26 nSubRecSiz(0),
27 nSubRecPos(0),
28 nMode(nNewMode),
29 bOpen(false)
31 OpenSubRecord();
34 old_SdrDownCompat::~old_SdrDownCompat()
36 if(bOpen)
37 CloseSubRecord();
40 void old_SdrDownCompat::Write()
42 rStream.WriteUInt32( nSubRecSiz );
45 void old_SdrDownCompat::OpenSubRecord()
47 if(rStream.GetError())
48 return;
50 nSubRecPos = rStream.Tell();
52 if(nMode == StreamMode::READ)
54 rStream.ReadUInt32( nSubRecSiz );
56 else if(nMode == StreamMode::WRITE)
58 Write();
61 bOpen = true;
64 void old_SdrDownCompat::CloseSubRecord()
66 if(rStream.GetError())
67 return;
69 sal_uInt32 nCurrentPos(rStream.Tell());
71 if(nMode == StreamMode::READ)
73 sal_uInt32 nReadCnt(nCurrentPos - nSubRecPos);
74 if(nReadCnt != nSubRecSiz)
76 rStream.Seek(nSubRecPos + nSubRecSiz);
79 else if(nMode == StreamMode::WRITE)
81 nSubRecSiz = nCurrentPos - nSubRecPos;
82 rStream.Seek(nSubRecPos);
83 Write();
84 rStream.Seek(nCurrentPos);
87 bOpen = false;
90 /*************************************************************************
92 |* Constructor, writes and reads version number
94 \************************************************************************/
96 SdIOCompat::SdIOCompat(SvStream& rNewStream, StreamMode nNewMode, sal_uInt16 nVersion)
97 : old_SdrDownCompat(rNewStream, nNewMode)
99 if (nNewMode == StreamMode::WRITE)
101 DBG_ASSERT(nVersion != SDIOCOMPAT_VERSIONDONTKNOW,
102 "can't write unknown version");
103 rNewStream.WriteUInt16( nVersion );
105 else if (nNewMode == StreamMode::READ)
107 DBG_ASSERT(nVersion == SDIOCOMPAT_VERSIONDONTKNOW,
108 "referring to the version while reading is silly!");
109 rNewStream.ReadUInt16( nVersion );
113 SdIOCompat::~SdIOCompat()
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */