LibreOffice Module sd (master) 1
sdiocmpt.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/debug.hxx>
21
22#include <sdiocmpt.hxx>
23
25: rStream(rNewStream),
26 nSubRecSiz(0),
27 nSubRecPos(0),
28 nMode(nNewMode),
29 bOpen(false)
30{
32}
33
35{
36 if(bOpen)
38}
39
41{
43}
44
46{
47 if(rStream.GetError())
48 return;
49
51
52 if(nMode == StreamMode::READ)
53 {
55 }
56 else if(nMode == StreamMode::WRITE)
57 {
58 Write();
59 }
60
61 bOpen = true;
62}
63
65{
66 if(rStream.GetError())
67 return;
68
69 sal_uInt32 nCurrentPos(rStream.Tell());
70
71 if(nMode == StreamMode::READ)
72 {
73 sal_uInt32 nReadCnt(nCurrentPos - nSubRecPos);
74 if(nReadCnt != nSubRecSiz)
75 {
77 }
78 }
79 else if(nMode == StreamMode::WRITE)
80 {
81 nSubRecSiz = nCurrentPos - nSubRecPos;
83 Write();
84 rStream.Seek(nCurrentPos);
85 }
86
87 bOpen = false;
88}
89
90/*************************************************************************
91|*
92|* Constructor, writes and reads version number
93|*
94\************************************************************************/
95
96SdIOCompat::SdIOCompat(SvStream& rNewStream, StreamMode nNewMode, sal_uInt16 nVersion)
97: old_SdrDownCompat(rNewStream, nNewMode)
98{
99 if (nNewMode == StreamMode::WRITE)
100 {
102 "can't write unknown version");
103 rNewStream.WriteUInt16( nVersion );
104 }
105 else if (nNewMode == StreamMode::READ)
106 {
108 "referring to the version while reading is silly!");
109 rNewStream.ReadUInt16( nVersion );
110 }
111}
112
114{
115}
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdIOCompat(SvStream &rNewStream, StreamMode nNewMode, sal_uInt16 nVer=SDIOCOMPAT_VERSIONDONTKNOW)
Definition: sdiocmpt.cxx:96
sal_uInt64 Tell() const
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
ErrCode GetError() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
SvStream & rStream
Definition: sdiocmpt.hxx:29
sal_uInt32 nSubRecPos
Definition: sdiocmpt.hxx:31
void OpenSubRecord()
Definition: sdiocmpt.cxx:45
void CloseSubRecord()
Definition: sdiocmpt.cxx:64
StreamMode nMode
Definition: sdiocmpt.hxx:32
old_SdrDownCompat(SvStream &rNewStream, StreamMode nNewMode)
Definition: sdiocmpt.cxx:24
sal_uInt32 nSubRecSiz
Definition: sdiocmpt.hxx:30
#define DBG_ASSERT(sCon, aError)
sal_Int16 nVersion
#define SDIOCOMPAT_VERSIONDONTKNOW
Definition: sdiocmpt.hxx:45
StreamMode