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