Branch data Line data Source code
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 : :
24 : : //////////////////////////////////////////////////////////////////////////////
25 : :
26 : 0 : old_SdrDownCompat::old_SdrDownCompat(SvStream& rNewStream, sal_uInt16 nNewMode)
27 : : : rStream(rNewStream),
28 : : nSubRecSiz(0),
29 : : nSubRecPos(0),
30 : : nMode(nNewMode),
31 : 0 : bOpen(sal_False)
32 : : {
33 : 0 : OpenSubRecord();
34 : 0 : }
35 : :
36 : 0 : old_SdrDownCompat::~old_SdrDownCompat()
37 : : {
38 [ # # ]: 0 : if(bOpen)
39 : 0 : CloseSubRecord();
40 : 0 : }
41 : :
42 : 0 : void old_SdrDownCompat::Read()
43 : : {
44 : 0 : rStream >> nSubRecSiz;
45 : 0 : }
46 : :
47 : 0 : void old_SdrDownCompat::Write()
48 : : {
49 : 0 : rStream << nSubRecSiz;
50 : 0 : }
51 : :
52 : 0 : void old_SdrDownCompat::OpenSubRecord()
53 : : {
54 [ # # ]: 0 : if(rStream.GetError())
55 : 0 : return;
56 : :
57 : 0 : nSubRecPos = rStream.Tell();
58 : :
59 [ # # ]: 0 : if(nMode == STREAM_READ)
60 : : {
61 : 0 : Read();
62 : : }
63 [ # # ]: 0 : else if(nMode == STREAM_WRITE)
64 : : {
65 : 0 : Write();
66 : : }
67 : :
68 : 0 : bOpen = sal_True;
69 : : }
70 : :
71 : 0 : void old_SdrDownCompat::CloseSubRecord()
72 : : {
73 [ # # ]: 0 : if(rStream.GetError())
74 : 0 : return;
75 : :
76 : 0 : sal_uInt32 nAktPos(rStream.Tell());
77 : :
78 [ # # ]: 0 : if(nMode == STREAM_READ)
79 : : {
80 : 0 : sal_uInt32 nReadAnz(nAktPos - nSubRecPos);
81 [ # # ]: 0 : if(nReadAnz != nSubRecSiz)
82 : : {
83 : 0 : rStream.Seek(nSubRecPos + nSubRecSiz);
84 : : }
85 : : }
86 [ # # ]: 0 : else if(nMode == STREAM_WRITE)
87 : : {
88 : 0 : nSubRecSiz = nAktPos - nSubRecPos;
89 : 0 : rStream.Seek(nSubRecPos);
90 : 0 : Write();
91 : 0 : rStream.Seek(nAktPos);
92 : : }
93 : :
94 : 0 : bOpen = sal_False;
95 : : }
96 : :
97 : : /*************************************************************************
98 : : |*
99 : : |* Konstruktor, schreibt bzw. liest Versionsnummer
100 : : |*
101 : : \************************************************************************/
102 : :
103 : 0 : SdIOCompat::SdIOCompat(SvStream& rNewStream, sal_uInt16 nNewMode, sal_uInt16 nVer)
104 : 0 : : old_SdrDownCompat(rNewStream, nNewMode), nVersion(nVer)
105 : : {
106 [ # # ]: 0 : if (nNewMode == STREAM_WRITE)
107 : : {
108 : : DBG_ASSERT(nVer != SDIOCOMPAT_VERSIONDONTKNOW,
109 : : "kann unbekannte Version nicht schreiben");
110 [ # # ]: 0 : rNewStream << nVersion;
111 : : }
112 [ # # ]: 0 : else if (nNewMode == STREAM_READ)
113 : : {
114 : : DBG_ASSERT(nVer == SDIOCOMPAT_VERSIONDONTKNOW,
115 : : "Lesen mit Angabe der Version ist Quatsch!");
116 [ # # ]: 0 : rNewStream >> nVersion;
117 : : }
118 : 0 : }
119 : :
120 : 0 : SdIOCompat::~SdIOCompat()
121 : : {
122 : 0 : }
123 : :
124 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|