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