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 : #ifndef SC_XCLIMPCHANGETRACK_HXX
21 : #define SC_XCLIMPCHANGETRACK_HXX
22 :
23 : #include <tools/datetime.hxx>
24 : #include "xiroot.hxx"
25 : #include "xistream.hxx"
26 : #include "excform.hxx"
27 : #include "imp_op.hxx"
28 :
29 :
30 : //___________________________________________________________________
31 :
32 : struct ScCellValue;
33 : class ScChangeAction;
34 : class ScChangeTrack;
35 : class XclImpChTrFmlConverter;
36 :
37 :
38 : //___________________________________________________________________
39 :
40 : struct XclImpChTrRecHeader
41 : {
42 : sal_uInt32 nSize;
43 : sal_uInt32 nIndex;
44 : sal_uInt16 nOpCode;
45 : sal_uInt16 nAccept;
46 : };
47 :
48 0 : inline XclImpStream& operator>>( XclImpStream& rStrm, XclImpChTrRecHeader& rRecHeader )
49 : {
50 0 : rStrm >> rRecHeader.nSize >> rRecHeader.nIndex >> rRecHeader.nOpCode >> rRecHeader.nAccept;
51 0 : return rStrm;
52 : }
53 :
54 : //___________________________________________________________________
55 :
56 : class XclImpChangeTrack : protected XclImpRoot
57 : {
58 : private:
59 : XclImpChTrRecHeader aRecHeader;
60 : String sOldUsername;
61 :
62 : ScChangeTrack* pChangeTrack;
63 : SotStorageStreamRef xInStrm; // input stream
64 : XclImpStream* pStrm; // stream import class
65 : sal_uInt16 nTabIdCount;
66 : sal_Bool bGlobExit; // global exit loop
67 :
68 : enum { nmBase, nmFound, nmNested }
69 : eNestedMode; // action with nested content actions
70 :
71 0 : inline sal_Bool FoundNestedMode() { return eNestedMode == nmFound; }
72 :
73 : void DoAcceptRejectAction( ScChangeAction* pAction );
74 : void DoAcceptRejectAction( sal_uInt32 nFirst, sal_uInt32 nLast );
75 :
76 : void DoInsertRange( const ScRange& rRange );
77 : void DoDeleteRange( const ScRange& rRange );
78 :
79 : inline sal_uInt8 LookAtuInt8();
80 : inline double ReadRK();
81 : inline sal_Bool ReadBool();
82 : inline void Read2DAddress( ScAddress& rAddress );
83 : inline void Read2DRange( ScRange& rRange );
84 : SCTAB ReadTabNum();
85 : void ReadDateTime( DateTime& rDateTime );
86 :
87 : inline void ReadString( String& rString );
88 :
89 : sal_Bool CheckRecord( sal_uInt16 nOpCode );
90 :
91 : void ReadFormula(
92 : ScTokenArray*& rpTokenArray,
93 : const ScAddress& rPosition );
94 : void ReadCell( ScCellValue& rCell, sal_uInt32& rFormat, sal_uInt16 nFlags, const ScAddress& rPosition );
95 :
96 : void ReadChTrInsert(); // 0x0137
97 : void ReadChTrInfo(); // 0x0138
98 : void ReadChTrCellContent(); // 0x013B
99 : void ReadChTrTabId(); // 0x013D
100 : void ReadChTrMoveRange(); // 0x0140
101 : void ReadChTrInsertTab(); // 0x014D
102 : void InitNestedMode(); // 0x014E, 0x0150
103 : void ReadNestedRecords();
104 : sal_Bool EndNestedMode(); // 0x014F, 0x0151
105 :
106 : void ReadRecords();
107 :
108 : public:
109 : XclImpChangeTrack( const XclImpRoot& rRoot, const XclImpStream& rBookStrm );
110 : ~XclImpChangeTrack();
111 :
112 : // reads extended 3D ref info following the formulas, returns sc tab nums
113 : // ( called by XclImpChTrFmlConverter::Read3DTabReference() )
114 : sal_Bool Read3DTabRefInfo( SCTAB& rFirstTab, SCTAB& rLastTab, ExcelToSc8::ExternalTabInfo& rExtInfo );
115 :
116 : void Apply();
117 : };
118 :
119 0 : inline sal_uInt8 XclImpChangeTrack::LookAtuInt8()
120 : {
121 0 : pStrm->PushPosition();
122 : sal_uInt8 nValue;
123 0 : *pStrm >> nValue;
124 0 : pStrm->PopPosition();
125 0 : return nValue;
126 : }
127 :
128 0 : inline double XclImpChangeTrack::ReadRK()
129 : {
130 0 : return XclTools::GetDoubleFromRK( pStrm->ReadInt32() );
131 : }
132 :
133 0 : inline sal_Bool XclImpChangeTrack::ReadBool()
134 : {
135 0 : return (pStrm->ReaduInt16() != 0);
136 : }
137 :
138 0 : inline void XclImpChangeTrack::Read2DAddress( ScAddress& rAddress )
139 : {
140 0 : rAddress.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
141 0 : rAddress.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
142 0 : }
143 :
144 0 : inline void XclImpChangeTrack::Read2DRange( ScRange& rRange )
145 : {
146 0 : rRange.aStart.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
147 0 : rRange.aEnd.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
148 0 : rRange.aStart.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
149 0 : rRange.aEnd.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
150 0 : }
151 :
152 : inline void XclImpChangeTrack::ReadString( String& rString )
153 : {
154 : rString = pStrm->ReadUniString();
155 : }
156 :
157 : //___________________________________________________________________
158 : // derived class for special 3D ref handling
159 :
160 : class XclImpChTrFmlConverter : public ExcelToSc8
161 : {
162 : private:
163 : XclImpChangeTrack& rChangeTrack;
164 :
165 : virtual bool Read3DTabReference( sal_uInt16 nIxti, SCTAB& rFirstTab, SCTAB& rLastTab, ExternalTabInfo& rExtInfo );
166 :
167 : public:
168 : inline XclImpChTrFmlConverter(
169 : const XclImpRoot& rRoot,
170 : XclImpChangeTrack& rXclChTr );
171 : virtual ~XclImpChTrFmlConverter();
172 : };
173 :
174 0 : inline XclImpChTrFmlConverter::XclImpChTrFmlConverter(
175 : const XclImpRoot& rRoot,
176 : XclImpChangeTrack& rXclChTr ) :
177 : ExcelToSc8( rRoot ),
178 0 : rChangeTrack( rXclChTr )
179 : {
180 0 : }
181 :
182 : //___________________________________________________________________
183 :
184 : #endif
185 :
186 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|