fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / core / sdiocmpt.cxx
blob0f4911231318a93e0ad457956d929fdc1c68f3cb
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 //////////////////////////////////////////////////////////////////////////////
26 old_SdrDownCompat::old_SdrDownCompat(SvStream& rNewStream, sal_uInt16 nNewMode)
27 : rStream(rNewStream),
28 nSubRecSiz(0),
29 nSubRecPos(0),
30 nMode(nNewMode),
31 bOpen(sal_False)
33 OpenSubRecord();
36 old_SdrDownCompat::~old_SdrDownCompat()
38 if(bOpen)
39 CloseSubRecord();
42 void old_SdrDownCompat::Read()
44 rStream >> nSubRecSiz;
47 void old_SdrDownCompat::Write()
49 rStream << nSubRecSiz;
52 void old_SdrDownCompat::OpenSubRecord()
54 if(rStream.GetError())
55 return;
57 nSubRecPos = rStream.Tell();
59 if(nMode == STREAM_READ)
61 Read();
63 else if(nMode == STREAM_WRITE)
65 Write();
68 bOpen = sal_True;
71 void old_SdrDownCompat::CloseSubRecord()
73 if(rStream.GetError())
74 return;
76 sal_uInt32 nAktPos(rStream.Tell());
78 if(nMode == STREAM_READ)
80 sal_uInt32 nReadAnz(nAktPos - nSubRecPos);
81 if(nReadAnz != nSubRecSiz)
83 rStream.Seek(nSubRecPos + nSubRecSiz);
86 else if(nMode == STREAM_WRITE)
88 nSubRecSiz = nAktPos - nSubRecPos;
89 rStream.Seek(nSubRecPos);
90 Write();
91 rStream.Seek(nAktPos);
94 bOpen = sal_False;
97 /*************************************************************************
99 |* Constructor, writes and reads version number
101 \************************************************************************/
103 SdIOCompat::SdIOCompat(SvStream& rNewStream, sal_uInt16 nNewMode, sal_uInt16 nVer)
104 : old_SdrDownCompat(rNewStream, nNewMode), nVersion(nVer)
106 if (nNewMode == STREAM_WRITE)
108 DBG_ASSERT(nVer != SDIOCOMPAT_VERSIONDONTKNOW,
109 "kann unbekannte Version nicht schreiben");
110 rNewStream << nVersion;
112 else if (nNewMode == STREAM_READ)
114 DBG_ASSERT(nVer == SDIOCOMPAT_VERSIONDONTKNOW,
115 "Lesen mit Angabe der Version ist Quatsch!");
116 rNewStream >> nVersion;
120 SdIOCompat::~SdIOCompat()
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */