LibreOffice Module sc (master)  1
XclImpChangeTrack.hxx
Go to the documentation of this file.
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 #pragma once
21 
22 #include "xiroot.hxx"
23 #include "xistream.hxx"
24 #include "excform.hxx"
25 
26 struct ScCellValue;
27 class ScChangeAction;
28 class ScChangeTrack;
29 class DateTime;
30 
32 {
33  sal_uInt32 nSize;
34  sal_uInt32 nIndex;
35  sal_uInt16 nOpCode;
36  sal_uInt16 nAccept;
37 };
38 
40 {
41  rRecHeader.nSize = rStrm.ReaduInt32();
42  rRecHeader.nIndex = rStrm.ReaduInt32();
43  rRecHeader.nOpCode = rStrm.ReaduInt16();
44  rRecHeader.nAccept = rStrm.ReaduInt16();
45  return rStrm;
46 }
47 
48 class XclImpChangeTrack : protected XclImpRoot
49 {
50 private:
52  OUString sOldUsername;
53 
54  std::unique_ptr<ScChangeTrack> pChangeTrack;
56  std::unique_ptr<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  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 void Read2DAddress( ScAddress& rAddress );
73  inline void Read2DRange( ScRange& rRange );
74  SCTAB ReadTabNum();
75  void ReadDateTime( DateTime& rDateTime );
76 
77  bool CheckRecord( sal_uInt16 nOpCode );
78 
79  void ReadFormula(
80  std::unique_ptr<ScTokenArray>& rpTokenArray,
81  const ScAddress& rPosition );
82  void ReadCell( ScCellValue& rCell, sal_uInt32& rFormat, sal_uInt16 nFlags, const ScAddress& rPosition );
83 
84  void ReadChTrInsert(); // 0x0137
85  void ReadChTrInfo(); // 0x0138
86  void ReadChTrCellContent(); // 0x013B
87  void ReadChTrTabId(); // 0x013D
88  void ReadChTrMoveRange(); // 0x0140
89  void ReadChTrInsertTab(); // 0x014D
90  void InitNestedMode(); // 0x014E, 0x0150
91  void ReadNestedRecords();
92  bool EndNestedMode(); // 0x014F, 0x0151
93 
94  void ReadRecords();
95 
96 public:
97  XclImpChangeTrack( const XclImpRoot& rRoot, const XclImpStream& rBookStrm );
98  virtual ~XclImpChangeTrack() override;
99 
100  // reads extended 3D ref info following the formulas, returns sc tab nums
101  // ( called by XclImpChTrFmlConverter::Read3DTabReference() )
102  void Read3DTabRefInfo( SCTAB& rFirstTab, SCTAB& rLastTab, ExcelToSc8::ExternalTabInfo& rExtInfo );
103 
104  void Apply();
105 };
106 
108 {
109  pStrm->PushPosition();
111  nValue = pStrm->ReaduInt8();
112  pStrm->PopPosition();
113  return nValue;
114 }
115 
117 {
118  rAddress.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
119  rAddress.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
120 }
121 
123 {
124  rRange.aStart.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
125  rRange.aEnd.SetRow( static_cast<SCROW>(pStrm->ReaduInt16()) );
126  rRange.aStart.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
127  rRange.aEnd.SetCol( static_cast<SCCOL>(pStrm->ReaduInt16()) );
128 }
129 
130 // derived class for special 3D ref handling
131 
133 {
134 private:
136 
137  virtual bool Read3DTabReference( sal_uInt16 nIxti, SCTAB& rFirstTab, SCTAB& rLastTab, ExternalTabInfo& rExtInfo ) override;
138 
139 public:
141  virtual ~XclImpChTrFmlConverter() override;
142 };
143 
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool Read3DTabReference(sal_uInt16 nIxti, SCTAB &rFirstTab, SCTAB &rLastTab, ExternalTabInfo &rExtInfo) override
ScAddress aStart
Definition: address.hxx:499
virtual ~XclImpChTrFmlConverter() override
ScAddress aEnd
Definition: address.hxx:500
void DoAcceptRejectAction(ScChangeAction *pAction)
Store arbitrary cell value of any kind.
Definition: cellvalue.hxx:35
XclImpChangeTrack(const XclImpRoot &rRoot, const XclImpStream &rBookStrm)
void ReadCell(ScCellValue &rCell, sal_uInt32 &rFormat, sal_uInt16 nFlags, const ScAddress &rPosition)
void SetRow(SCROW nRowP)
Definition: address.hxx:274
void SetCol(SCCOL nColP)
Definition: address.hxx:278
virtual ~XclImpChangeTrack() override
XclImpChTrFmlConverter(XclImpRoot &rRoot, XclImpChangeTrack &rXclChTr)
enum XclImpChangeTrack::@3 eNestedMode
void DoDeleteRange(const ScRange &rRange)
void ReadFormula(std::unique_ptr< ScTokenArray > &rpTokenArray, const ScAddress &rPosition)
sal_uInt16 ReaduInt16()
Definition: xistream.cxx:649
XclImpChangeTrack & rChangeTrack
unsigned char sal_uInt8
tools::SvRef< SotStorageStream > xInStrm
void Read2DRange(ScRange &rRange)
XclImpStream & operator>>(XclImpStream &rStrm, XclImpChTrRecHeader &rRecHeader)
bool CheckRecord(sal_uInt16 nOpCode)
This class is used to import record oriented streams.
Definition: xistream.hxx:277
void Read3DTabRefInfo(SCTAB &rFirstTab, SCTAB &rLastTab, ExcelToSc8::ExternalTabInfo &rExtInfo)
void DoInsertRange(const ScRange &rRange, bool bEndOfList)
void Read2DAddress(ScAddress &rAddress)
Access to global data from other classes.
Definition: xiroot.hxx:125
sal_uInt32 ReaduInt32()
Definition: xistream.cxx:685
void ReadDateTime(DateTime &rDateTime)
std::unique_ptr< ScChangeTrack > pChangeTrack
std::unique_ptr< XclImpStream > pStrm
sal_Int16 SCTAB
Definition: types.hxx:22
XclImpChTrRecHeader aRecHeader
sal_Int16 nValue