1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef SC_XCLIMPCHANGETRACK_HXX
25 #define SC_XCLIMPCHANGETRACK_HXX
26
27 #include <tools/datetime.hxx>
28 #include "xiroot.hxx"
29 #include "xistream.hxx"
30 #include "excform.hxx"
31 #include "imp_op.hxx"
32
33
34 //___________________________________________________________________
35
36 class ScBaseCell;
37 class ScChangeAction;
38 class ScChangeTrack;
39 class XclImpChTrFmlConverter;
40
41 //___________________________________________________________________
42
43 struct XclImpChTrRecHeader
44 {
45 sal_uInt32 nSize;
46 sal_uInt32 nIndex;
47 sal_uInt16 nOpCode;
48 sal_uInt16 nAccept;
49 };
50
operator >>(XclImpStream & rStrm,XclImpChTrRecHeader & rRecHeader)51 inline XclImpStream& operator>>( XclImpStream& rStrm, XclImpChTrRecHeader& rRecHeader )
52 {
53 rStrm >> rRecHeader.nSize >> rRecHeader.nIndex >> rRecHeader.nOpCode >> rRecHeader.nAccept;
54 return rStrm;
55 }
56
57 //___________________________________________________________________
58
59 class XclImpChangeTrack : protected XclImpRoot
60 {
61 private:
62 XclImpChTrRecHeader aRecHeader;
63 String sOldUsername;
64
65 ScChangeTrack* pChangeTrack;
66 SotStorageStreamRef xInStrm; // input stream
67 XclImpStream* pStrm; // stream import class
68 sal_uInt16 nTabIdCount;
69 sal_Bool bGlobExit; // global exit loop
70
71 enum { nmBase, nmFound, nmNested }
72 eNestedMode; // action with nested content actions
73
FoundNestedMode()74 inline sal_Bool FoundNestedMode() { return eNestedMode == nmFound; }
75
76 void DoAcceptRejectAction( ScChangeAction* pAction );
77 void DoAcceptRejectAction( sal_uInt32 nFirst, sal_uInt32 nLast );
78
79 void DoInsertRange( const ScRange& rRange );
80 void DoDeleteRange( const ScRange& rRange );
81
82 inline sal_uInt8 LookAtuInt8();
83 inline double ReadRK();
84 inline sal_Bool ReadBool();
85 inline void Read2DAddress( ScAddress& rAddress );
86 inline void Read2DRange( ScRange& rRange );
87 SCTAB ReadTabNum();
88 void ReadDateTime( DateTime& rDateTime );
89
90 inline void ReadString( String& rString );
91 inline void IgnoreString();
92
93 sal_Bool CheckRecord( sal_uInt16 nOpCode );
94
95 void ReadFormula(
96 ScTokenArray*& rpTokenArray,
97 const ScAddress& rPosition );
98 void ReadCell(
99 ScBaseCell*& rpCell,
100 sal_uInt32& rFormat,
101 sal_uInt16 nFlags,
102 const ScAddress& rPosition );
103
104 void ReadChTrInsert(); // 0x0137
105 void ReadChTrInfo(); // 0x0138
106 void ReadChTrCellContent(); // 0x013B
107 void ReadChTrTabId(); // 0x013D
108 void ReadChTrMoveRange(); // 0x0140
109 void ReadChTrInsertTab(); // 0x014D
110 void InitNestedMode(); // 0x014E, 0x0150
111 void ReadNestedRecords();
112 sal_Bool EndNestedMode(); // 0x014F, 0x0151
113
114 void ReadRecords();
115
116 public:
117 XclImpChangeTrack( const XclImpRoot& rRoot, const XclImpStream& rBookStrm );
118 ~XclImpChangeTrack();
119
120 // reads extended 3D ref info following the formulas, returns sc tab nums
121 // ( called by XclImpChTrFmlConverter::Read3DTabReference() )
122 sal_Bool Read3DTabRefInfo( SCTAB& rFirstTab, SCTAB& rLastTab, ExcelToSc8::ExternalTabInfo& rExtInfo );
123
124 void Apply();
125 };
126
LookAtuInt8()127 inline sal_uInt8 XclImpChangeTrack::LookAtuInt8()
128 {
129 pStrm->PushPosition();
130 sal_uInt8 nValue;
131 *pStrm >> nValue;
132 pStrm->PopPosition();
133 return nValue;
134 }
135
ReadRK()136 inline double XclImpChangeTrack::ReadRK()
137 {
138 return XclTools::GetDoubleFromRK( pStrm->ReadInt32() );
139 }
140
ReadBool()141 inline sal_Bool XclImpChangeTrack::ReadBool()
142 {
143 return (pStrm->ReaduInt16() != 0);
144 }
145
Read2DAddress(ScAddress & rAddress)146 inline void XclImpChangeTrack::Read2DAddress( ScAddress& rAddress )
147 {
148 rAddress.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
149 rAddress.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
150 }
151
Read2DRange(ScRange & rRange)152 inline void XclImpChangeTrack::Read2DRange( ScRange& rRange )
153 {
154 rRange.aStart.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
155 rRange.aEnd.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
156 rRange.aStart.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
157 rRange.aEnd.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
158 }
159
ReadString(String & rString)160 inline void XclImpChangeTrack::ReadString( String& rString )
161 {
162 rString = pStrm->ReadUniString();
163 }
164
IgnoreString()165 inline void XclImpChangeTrack::IgnoreString()
166 {
167 pStrm->IgnoreUniString();
168 }
169
170 //___________________________________________________________________
171 // derived class for special 3D ref handling
172
173 class XclImpChTrFmlConverter : public ExcelToSc8
174 {
175 private:
176 XclImpChangeTrack& rChangeTrack;
177
178 virtual bool Read3DTabReference( sal_uInt16 nIxti, SCTAB& rFirstTab, SCTAB& rLastTab, ExternalTabInfo& rExtInfo );
179
180 public:
181 inline XclImpChTrFmlConverter(
182 const XclImpRoot& rRoot,
183 XclImpChangeTrack& rXclChTr );
184 virtual ~XclImpChTrFmlConverter();
185 };
186
XclImpChTrFmlConverter(const XclImpRoot & rRoot,XclImpChangeTrack & rXclChTr)187 inline XclImpChTrFmlConverter::XclImpChTrFmlConverter(
188 const XclImpRoot& rRoot,
189 XclImpChangeTrack& rXclChTr ) :
190 ExcelToSc8( rRoot ),
191 rChangeTrack( rXclChTr )
192 {
193 }
194
195 //___________________________________________________________________
196
197 #endif
198
199