Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_XCLIMPCHANGETRACK_HXX
30 : : #define SC_XCLIMPCHANGETRACK_HXX
31 : :
32 : : #include <tools/datetime.hxx>
33 : : #include "xiroot.hxx"
34 : : #include "xistream.hxx"
35 : : #include "excform.hxx"
36 : : #include "imp_op.hxx"
37 : :
38 : :
39 : : //___________________________________________________________________
40 : :
41 : : class ScBaseCell;
42 : : class ScChangeAction;
43 : : class ScChangeTrack;
44 : : class XclImpChTrFmlConverter;
45 : :
46 : : //___________________________________________________________________
47 : :
48 : : struct XclImpChTrRecHeader
49 : : {
50 : : sal_uInt32 nSize;
51 : : sal_uInt32 nIndex;
52 : : sal_uInt16 nOpCode;
53 : : sal_uInt16 nAccept;
54 : : };
55 : :
56 : 0 : inline XclImpStream& operator>>( XclImpStream& rStrm, XclImpChTrRecHeader& rRecHeader )
57 : : {
58 : 0 : rStrm >> rRecHeader.nSize >> rRecHeader.nIndex >> rRecHeader.nOpCode >> rRecHeader.nAccept;
59 : 0 : return rStrm;
60 : : }
61 : :
62 : : //___________________________________________________________________
63 : :
64 : : class XclImpChangeTrack : protected XclImpRoot
65 : : {
66 : : private:
67 : : XclImpChTrRecHeader aRecHeader;
68 : : String sOldUsername;
69 : :
70 : : ScChangeTrack* pChangeTrack;
71 : : SotStorageStreamRef xInStrm; // input stream
72 : : XclImpStream* pStrm; // stream import class
73 : : sal_uInt16 nTabIdCount;
74 : : sal_Bool bGlobExit; // global exit loop
75 : :
76 : : enum { nmBase, nmFound, nmNested }
77 : : eNestedMode; // action with nested content actions
78 : :
79 : 0 : inline sal_Bool FoundNestedMode() { return eNestedMode == nmFound; }
80 : :
81 : : void DoAcceptRejectAction( ScChangeAction* pAction );
82 : : void DoAcceptRejectAction( sal_uInt32 nFirst, sal_uInt32 nLast );
83 : :
84 : : void DoInsertRange( const ScRange& rRange );
85 : : void DoDeleteRange( const ScRange& rRange );
86 : :
87 : : inline sal_uInt8 LookAtuInt8();
88 : : inline double ReadRK();
89 : : inline sal_Bool ReadBool();
90 : : inline void Read2DAddress( ScAddress& rAddress );
91 : : inline void Read2DRange( ScRange& rRange );
92 : : SCTAB ReadTabNum();
93 : : void ReadDateTime( DateTime& rDateTime );
94 : :
95 : : inline void ReadString( String& rString );
96 : :
97 : : sal_Bool CheckRecord( sal_uInt16 nOpCode );
98 : :
99 : : void ReadFormula(
100 : : ScTokenArray*& rpTokenArray,
101 : : const ScAddress& rPosition );
102 : : void ReadCell(
103 : : ScBaseCell*& rpCell,
104 : : sal_uInt32& rFormat,
105 : : sal_uInt16 nFlags,
106 : : const ScAddress& rPosition );
107 : :
108 : : void ReadChTrInsert(); // 0x0137
109 : : void ReadChTrInfo(); // 0x0138
110 : : void ReadChTrCellContent(); // 0x013B
111 : : void ReadChTrTabId(); // 0x013D
112 : : void ReadChTrMoveRange(); // 0x0140
113 : : void ReadChTrInsertTab(); // 0x014D
114 : : void InitNestedMode(); // 0x014E, 0x0150
115 : : void ReadNestedRecords();
116 : : sal_Bool EndNestedMode(); // 0x014F, 0x0151
117 : :
118 : : void ReadRecords();
119 : :
120 : : public:
121 : : XclImpChangeTrack( const XclImpRoot& rRoot, const XclImpStream& rBookStrm );
122 : : ~XclImpChangeTrack();
123 : :
124 : : // reads extended 3D ref info following the formulas, returns sc tab nums
125 : : // ( called by XclImpChTrFmlConverter::Read3DTabReference() )
126 : : sal_Bool Read3DTabRefInfo( SCTAB& rFirstTab, SCTAB& rLastTab, ExcelToSc8::ExternalTabInfo& rExtInfo );
127 : :
128 : : void Apply();
129 : : };
130 : :
131 : 0 : inline sal_uInt8 XclImpChangeTrack::LookAtuInt8()
132 : : {
133 [ # # ]: 0 : pStrm->PushPosition();
134 : : sal_uInt8 nValue;
135 [ # # ]: 0 : *pStrm >> nValue;
136 [ # # ]: 0 : pStrm->PopPosition();
137 : 0 : return nValue;
138 : : }
139 : :
140 : 0 : inline double XclImpChangeTrack::ReadRK()
141 : : {
142 : 0 : return XclTools::GetDoubleFromRK( pStrm->ReadInt32() );
143 : : }
144 : :
145 : 0 : inline sal_Bool XclImpChangeTrack::ReadBool()
146 : : {
147 : 0 : return (pStrm->ReaduInt16() != 0);
148 : : }
149 : :
150 : 0 : inline void XclImpChangeTrack::Read2DAddress( ScAddress& rAddress )
151 : : {
152 : 0 : rAddress.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
153 : 0 : rAddress.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
154 : 0 : }
155 : :
156 : 0 : inline void XclImpChangeTrack::Read2DRange( ScRange& rRange )
157 : : {
158 : 0 : rRange.aStart.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
159 : 0 : rRange.aEnd.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
160 : 0 : rRange.aStart.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
161 : 0 : rRange.aEnd.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
162 : 0 : }
163 : :
164 : : inline void XclImpChangeTrack::ReadString( String& rString )
165 : : {
166 : : rString = pStrm->ReadUniString();
167 : : }
168 : :
169 : : //___________________________________________________________________
170 : : // derived class for special 3D ref handling
171 : :
172 : : class XclImpChTrFmlConverter : public ExcelToSc8
173 : : {
174 : : private:
175 : : XclImpChangeTrack& rChangeTrack;
176 : :
177 : : virtual bool Read3DTabReference( sal_uInt16 nIxti, SCTAB& rFirstTab, SCTAB& rLastTab, ExternalTabInfo& rExtInfo );
178 : :
179 : : public:
180 : : inline XclImpChTrFmlConverter(
181 : : const XclImpRoot& rRoot,
182 : : XclImpChangeTrack& rXclChTr );
183 : : virtual ~XclImpChTrFmlConverter();
184 : : };
185 : :
186 : 0 : inline XclImpChTrFmlConverter::XclImpChTrFmlConverter(
187 : : const XclImpRoot& rRoot,
188 : : XclImpChangeTrack& rXclChTr ) :
189 : : ExcelToSc8( rRoot ),
190 : 0 : rChangeTrack( rXclChTr )
191 : : {
192 : 0 : }
193 : :
194 : : //___________________________________________________________________
195 : :
196 : : #endif
197 : :
198 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|