Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / XclImpChangeTrack.hxx
blob532cc9e324642e0f801f92cd906fbba7c02c1705
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 #pragma once
22 #include "xiroot.hxx"
23 #include "xistream.hxx"
24 #include "excform.hxx"
26 struct ScCellValue;
27 class ScChangeAction;
28 class ScChangeTrack;
29 class DateTime;
31 struct XclImpChTrRecHeader
33 sal_uInt32 nSize;
34 sal_uInt32 nIndex;
35 sal_uInt16 nOpCode;
36 sal_uInt16 nAccept;
39 inline XclImpStream& operator>>( XclImpStream& rStrm, XclImpChTrRecHeader& rRecHeader )
41 rRecHeader.nSize = rStrm.ReaduInt32();
42 rRecHeader.nIndex = rStrm.ReaduInt32();
43 rRecHeader.nOpCode = rStrm.ReaduInt16();
44 rRecHeader.nAccept = rStrm.ReaduInt16();
45 return rStrm;
48 class XclImpChangeTrack : protected XclImpRoot
50 private:
51 XclImpChTrRecHeader aRecHeader;
52 OUString sOldUsername;
54 std::unique_ptr<ScChangeTrack> pChangeTrack;
55 tools::SvRef<SotStorageStream> xInStrm; // input stream
56 std::unique_ptr<XclImpStream> pStrm; // stream import class
57 sal_uInt16 nTabIdCount;
58 bool bGlobExit; // global exit loop
60 enum { nmBase, nmFound, nmNested }
61 eNestedMode; // action with nested content actions
63 bool FoundNestedMode() { return eNestedMode == nmFound; }
65 void DoAcceptRejectAction( ScChangeAction* pAction );
66 void DoAcceptRejectAction( sal_uInt32 nFirst, sal_uInt32 nLast );
68 void DoInsertRange( const ScRange& rRange, bool bEndOfList );
69 void DoDeleteRange( const ScRange& rRange );
71 inline sal_uInt8 LookAtuInt8();
72 inline void Read2DAddress( ScAddress& rAddress );
73 inline void Read2DRange( ScRange& rRange );
74 SCTAB ReadTabNum();
75 void ReadDateTime( DateTime& rDateTime );
77 bool CheckRecord( sal_uInt16 nOpCode );
79 void ReadFormula(
80 std::unique_ptr<ScTokenArray>& rpTokenArray,
81 const ScAddress& rPosition );
82 void ReadCell( ScCellValue& rCell, sal_uInt32& rFormat, sal_uInt16 nFlags, const ScAddress& rPosition );
84 void ReadChTrInsert(); // 0x0137
85 void ReadChTrInfo(); // 0x0138
86 void ReadChTrCellContent(); // 0x013B
87 void ReadChTrTabId(); // 0x013D
88 void ReadChTrMoveRange(); // 0x0140
89 void ReadChTrInsertTab(); // 0x014D
90 void InitNestedMode(); // 0x014E, 0x0150
91 void ReadNestedRecords();
92 bool EndNestedMode(); // 0x014F, 0x0151
94 void ReadRecords();
96 public:
97 XclImpChangeTrack( const XclImpRoot& rRoot, const XclImpStream& rBookStrm );
98 virtual ~XclImpChangeTrack() override;
100 // reads extended 3D ref info following the formulas, returns sc tab nums
101 // ( called by XclImpChTrFmlConverter::Read3DTabReference() )
102 void Read3DTabRefInfo( SCTAB& rFirstTab, SCTAB& rLastTab, ExcelToSc8::ExternalTabInfo& rExtInfo );
104 void Apply();
107 inline sal_uInt8 XclImpChangeTrack::LookAtuInt8()
109 pStrm->PushPosition();
110 sal_uInt8 nValue;
111 nValue = pStrm->ReaduInt8();
112 pStrm->PopPosition();
113 return nValue;
116 inline void XclImpChangeTrack::Read2DAddress( ScAddress& rAddress )
118 rAddress.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
119 rAddress.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
122 inline void XclImpChangeTrack::Read2DRange( ScRange& rRange )
124 rRange.aStart.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
125 rRange.aEnd.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
126 rRange.aStart.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
127 rRange.aEnd.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
130 // derived class for special 3D ref handling
132 class XclImpChTrFmlConverter : public ExcelToSc8
134 private:
135 XclImpChangeTrack& rChangeTrack;
137 virtual bool Read3DTabReference( sal_uInt16 nIxti, SCTAB& rFirstTab, SCTAB& rLastTab, ExternalTabInfo& rExtInfo ) override;
139 public:
140 XclImpChTrFmlConverter( XclImpRoot& rRoot, XclImpChangeTrack& rXclChTr );
141 virtual ~XclImpChTrFmlConverter() override;
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */