1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XCLIMPCHANGETRACK_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XCLIMPCHANGETRACK_HXX
23 #include <tools/datetime.hxx>
25 #include "xistream.hxx"
26 #include "excform.hxx"
32 class XclImpChTrFmlConverter
;
34 struct XclImpChTrRecHeader
42 inline XclImpStream
& operator>>( XclImpStream
& rStrm
, XclImpChTrRecHeader
& rRecHeader
)
44 rRecHeader
.nSize
= rStrm
.ReaduInt32();
45 rRecHeader
.nIndex
= rStrm
.ReaduInt32();
46 rRecHeader
.nOpCode
= rStrm
.ReaduInt16();
47 rRecHeader
.nAccept
= rStrm
.ReaduInt16();
51 class XclImpChangeTrack
: protected XclImpRoot
54 XclImpChTrRecHeader aRecHeader
;
55 OUString sOldUsername
;
57 ScChangeTrack
* pChangeTrack
;
58 tools::SvRef
<SotStorageStream
> xInStrm
; // input stream
59 XclImpStream
* pStrm
; // stream import class
60 sal_uInt16 nTabIdCount
;
61 bool bGlobExit
; // global exit loop
63 enum { nmBase
, nmFound
, nmNested
}
64 eNestedMode
; // action with nested content actions
66 inline bool FoundNestedMode() { return eNestedMode
== nmFound
; }
68 void DoAcceptRejectAction( ScChangeAction
* pAction
);
69 void DoAcceptRejectAction( sal_uInt32 nFirst
, sal_uInt32 nLast
);
71 void DoInsertRange( const ScRange
& rRange
, bool bEndOfList
);
72 void DoDeleteRange( const ScRange
& rRange
);
74 inline sal_uInt8
LookAtuInt8();
75 inline double ReadRK();
76 inline bool ReadBool();
77 inline void Read2DAddress( ScAddress
& rAddress
);
78 inline void Read2DRange( ScRange
& rRange
);
80 void ReadDateTime( DateTime
& rDateTime
);
82 inline void ReadString( OUString
& rString
);
84 bool CheckRecord( sal_uInt16 nOpCode
);
87 ScTokenArray
*& rpTokenArray
,
88 const ScAddress
& rPosition
);
89 void ReadCell( ScCellValue
& rCell
, sal_uInt32
& rFormat
, sal_uInt16 nFlags
, const ScAddress
& rPosition
);
91 void ReadChTrInsert(); // 0x0137
92 void ReadChTrInfo(); // 0x0138
93 void ReadChTrCellContent(); // 0x013B
94 void ReadChTrTabId(); // 0x013D
95 void ReadChTrMoveRange(); // 0x0140
96 void ReadChTrInsertTab(); // 0x014D
97 void InitNestedMode(); // 0x014E, 0x0150
98 void ReadNestedRecords();
99 bool EndNestedMode(); // 0x014F, 0x0151
104 XclImpChangeTrack( const XclImpRoot
& rRoot
, const XclImpStream
& rBookStrm
);
105 virtual ~XclImpChangeTrack();
107 // reads extended 3D ref info following the formulas, returns sc tab nums
108 // ( called by XclImpChTrFmlConverter::Read3DTabReference() )
109 bool Read3DTabRefInfo( SCTAB
& rFirstTab
, SCTAB
& rLastTab
, ExcelToSc8::ExternalTabInfo
& rExtInfo
);
114 inline sal_uInt8
XclImpChangeTrack::LookAtuInt8()
116 pStrm
->PushPosition();
118 nValue
= pStrm
->ReaduInt8();
119 pStrm
->PopPosition();
123 inline double XclImpChangeTrack::ReadRK()
125 return XclTools::GetDoubleFromRK( pStrm
->ReadInt32() );
128 inline bool XclImpChangeTrack::ReadBool()
130 return (pStrm
->ReaduInt16() != 0);
133 inline void XclImpChangeTrack::Read2DAddress( ScAddress
& rAddress
)
135 rAddress
.SetRow( static_cast<SCROW
>(pStrm
->ReaduInt16()) );
136 rAddress
.SetCol( static_cast<SCCOL
>(pStrm
->ReaduInt16()) );
139 inline void XclImpChangeTrack::Read2DRange( ScRange
& rRange
)
141 rRange
.aStart
.SetRow( static_cast<SCROW
>(pStrm
->ReaduInt16()) );
142 rRange
.aEnd
.SetRow( static_cast<SCROW
>(pStrm
->ReaduInt16()) );
143 rRange
.aStart
.SetCol( static_cast<SCCOL
>(pStrm
->ReaduInt16()) );
144 rRange
.aEnd
.SetCol( static_cast<SCCOL
>(pStrm
->ReaduInt16()) );
147 inline void XclImpChangeTrack::ReadString( OUString
& rString
)
149 rString
= pStrm
->ReadUniString();
152 // derived class for special 3D ref handling
154 class XclImpChTrFmlConverter
: public ExcelToSc8
157 XclImpChangeTrack
& rChangeTrack
;
159 virtual bool Read3DTabReference( sal_uInt16 nIxti
, SCTAB
& rFirstTab
, SCTAB
& rLastTab
, ExternalTabInfo
& rExtInfo
) SAL_OVERRIDE
;
162 XclImpChTrFmlConverter( XclImpRoot
& rRoot
, XclImpChangeTrack
& rXclChTr
);
163 virtual ~XclImpChTrFmlConverter();
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */