1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SC_XCLIMPCHANGETRACK_HXX
29 #define SC_XCLIMPCHANGETRACK_HXX
31 #include <tools/datetime.hxx>
33 #include "xistream.hxx"
34 #include "excform.hxx"
38 //___________________________________________________________________
43 class XclImpChTrFmlConverter
;
45 //___________________________________________________________________
47 struct XclImpChTrRecHeader
55 inline XclImpStream
& operator>>( XclImpStream
& rStrm
, XclImpChTrRecHeader
& rRecHeader
)
57 rStrm
>> rRecHeader
.nSize
>> rRecHeader
.nIndex
>> rRecHeader
.nOpCode
>> rRecHeader
.nAccept
;
61 //___________________________________________________________________
63 class XclImpChangeTrack
: protected XclImpRoot
66 XclImpChTrRecHeader aRecHeader
;
69 ScChangeTrack
* pChangeTrack
;
70 SotStorageStreamRef xInStrm
; // input stream
71 XclImpStream
* pStrm
; // stream import class
72 sal_uInt16 nTabIdCount
;
73 sal_Bool bGlobExit
; // global exit loop
75 enum { nmBase
, nmFound
, nmNested
}
76 eNestedMode
; // action with nested content actions
78 inline sal_Bool
FoundNestedMode() { return eNestedMode
== nmFound
; }
80 void DoAcceptRejectAction( ScChangeAction
* pAction
);
81 void DoAcceptRejectAction( sal_uInt32 nFirst
, sal_uInt32 nLast
);
83 void DoInsertRange( const ScRange
& rRange
);
84 void DoDeleteRange( const ScRange
& rRange
);
86 inline sal_uInt8
LookAtuInt8();
87 inline double ReadRK();
88 inline sal_Bool
ReadBool();
89 inline void Read2DAddress( ScAddress
& rAddress
);
90 inline void Read2DRange( ScRange
& rRange
);
92 void ReadDateTime( DateTime
& rDateTime
);
94 inline void ReadString( String
& rString
);
95 inline void IgnoreString();
97 sal_Bool
CheckRecord( sal_uInt16 nOpCode
);
100 ScTokenArray
*& rpTokenArray
,
101 const ScAddress
& rPosition
);
106 const ScAddress
& rPosition
);
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
121 XclImpChangeTrack( const XclImpRoot
& rRoot
, const XclImpStream
& rBookStrm
);
122 ~XclImpChangeTrack();
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
);
131 inline sal_uInt8
XclImpChangeTrack::LookAtuInt8()
133 pStrm
->PushPosition();
136 pStrm
->PopPosition();
140 inline double XclImpChangeTrack::ReadRK()
142 return XclTools::GetDoubleFromRK( pStrm
->ReadInt32() );
145 inline sal_Bool
XclImpChangeTrack::ReadBool()
147 return (pStrm
->ReaduInt16() != 0);
150 inline void XclImpChangeTrack::Read2DAddress( ScAddress
& rAddress
)
152 rAddress
.SetRow( static_cast<SCROW
>(pStrm
->ReaduInt16()) );
153 rAddress
.SetCol( static_cast<SCCOL
>(pStrm
->ReaduInt16()) );
156 inline void XclImpChangeTrack::Read2DRange( ScRange
& rRange
)
158 rRange
.aStart
.SetRow( static_cast<SCROW
>(pStrm
->ReaduInt16()) );
159 rRange
.aEnd
.SetRow( static_cast<SCROW
>(pStrm
->ReaduInt16()) );
160 rRange
.aStart
.SetCol( static_cast<SCCOL
>(pStrm
->ReaduInt16()) );
161 rRange
.aEnd
.SetCol( static_cast<SCCOL
>(pStrm
->ReaduInt16()) );
164 inline void XclImpChangeTrack::ReadString( String
& rString
)
166 rString
= pStrm
->ReadUniString();
169 inline void XclImpChangeTrack::IgnoreString()
171 pStrm
->IgnoreUniString();
174 //___________________________________________________________________
175 // derived class for special 3D ref handling
177 class XclImpChTrFmlConverter
: public ExcelToSc8
180 XclImpChangeTrack
& rChangeTrack
;
182 virtual bool Read3DTabReference( UINT16 nIxti
, SCTAB
& rFirstTab
, SCTAB
& rLastTab
, ExternalTabInfo
& rExtInfo
);
185 inline XclImpChTrFmlConverter(
186 const XclImpRoot
& rRoot
,
187 XclImpChangeTrack
& rXclChTr
);
188 virtual ~XclImpChTrFmlConverter();
191 inline XclImpChTrFmlConverter::XclImpChTrFmlConverter(
192 const XclImpRoot
& rRoot
,
193 XclImpChangeTrack
& rXclChTr
) :
195 rChangeTrack( rXclChTr
)
199 //___________________________________________________________________