1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: XclExpChangeTrack.hxx,v $
* $Revision: 1.20 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SC_XCLEXPCHANGETRACK_HXX
#define SC_XCLEXPCHANGETRACK_HXX
#include <tools/debug.hxx>
#include <tools/datetime.hxx>
#include <rtl/uuid.h>
#include "bigrange.hxx"
#include "chgtrack.hxx"
#include "xelink.hxx"
#include "ftools.hxx"
#include "excrecds.hxx"
//___________________________________________________________________
class ScBaseCell;
//___________________________________________________________________
// XclExpUserBView - one UserBView record for each user
class XclExpUserBView : public ExcRecord
{
private:
XclExpString sUsername;
sal_uInt8 aGUID[ 16 ];
virtual void SaveCont( XclExpStream& rStrm );
public:
XclExpUserBView( const String& rUsername, const sal_uInt8* pGUID );
inline const sal_uInt8* GetGUID() const { return aGUID; }
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// XclExpUserBViewList - list of UserBView records
class XclExpUserBViewList : public ExcEmptyRec, private List
{
private:
inline XclExpUserBView* _First() { return (XclExpUserBView*) List::First(); }
inline XclExpUserBView* _Next() { return (XclExpUserBView*) List::Next(); }
public:
XclExpUserBViewList( const ScChangeTrack& rChangeTrack );
virtual ~XclExpUserBViewList();
inline const XclExpUserBView* First() { return (const XclExpUserBView*) List::First(); }
inline const XclExpUserBView* Next() { return (const XclExpUserBView*) List::Next(); }
virtual void Save( XclExpStream& rStrm );
};
//___________________________________________________________________
// XclExpUsersViewBegin - begin of view block (one per sheet)
class XclExpUsersViewBegin : public ExcRecord
{
private:
sal_uInt8 aGUID[ 16 ];
sal_uInt32 nCurrTab;
virtual void SaveCont( XclExpStream& rStrm );
public:
XclExpUsersViewBegin( const sal_uInt8* pGUID, sal_uInt32 nTab );
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// XclExpUsersViewEnd - end of view block (one per sheet)
class XclExpUsersViewEnd : public ExcRecord
{
private:
virtual void SaveCont( XclExpStream& rStrm );
public:
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// dummy record for "User Names" stream
class XclExpChTr0x0191 : public ExcRecord
{
private:
virtual void SaveCont( XclExpStream& rStrm );
public:
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// dummy record for "User Names" stream
class XclExpChTr0x0198 : public ExcRecord
{
private:
virtual void SaveCont( XclExpStream& rStrm );
public:
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// dummy record for "User Names" stream
class XclExpChTr0x0192 : public ExcRecord
{
private:
virtual void SaveCont( XclExpStream& rStrm );
public:
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// dummy record for "User Names" stream
class XclExpChTr0x0197 : public ExcRecord
{
private:
virtual void SaveCont( XclExpStream& rStrm );
public:
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// dummy record without content
class XclExpChTrEmpty : public ExcRecord
{
private:
UINT16 nRecNum;
public:
inline XclExpChTrEmpty( UINT16 nNum ) : nRecNum( nNum ) {}
virtual ~XclExpChTrEmpty();
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// dummy record for "Revision Log" stream
class XclExpChTr0x0195 : public ExcRecord
{
private:
virtual void SaveCont( XclExpStream& rStrm );
public:
virtual ~XclExpChTr0x0195();
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// dummy record for "Revision Log" stream
class XclExpChTr0x0194 : public ExcRecord
{
private:
XclExpString sUsername;
DateTime aDateTime;
virtual void SaveCont( XclExpStream& rStrm );
public:
inline XclExpChTr0x0194( const ScChangeTrack& rChangeTrack );
virtual ~XclExpChTr0x0194();
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
inline XclExpChTr0x0194::XclExpChTr0x0194( const ScChangeTrack& rChangeTrack ) :
sUsername( rChangeTrack.GetUser() ),
aDateTime( rChangeTrack.GetFixDateTime() )
{
}
//___________________________________________________________________
// XclExpChTrHeader - header record, includes action count
class XclExpChTrHeader : public ExcRecord
{
private:
sal_uInt8 aGUID[ 16 ];
sal_uInt32 nCount;
virtual void SaveCont( XclExpStream& rStrm );
public:
inline XclExpChTrHeader() : nCount( 0 ) {}
virtual ~XclExpChTrHeader();
inline void SetGUID( const sal_uInt8* pGUID ) { memcpy( aGUID, pGUID, 16 ); }
inline void SetCount( sal_uInt32 nNew ) { nCount = nNew; }
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// XclExpChTrInfo - header of action group of a user
class XclExpChTrInfo : public ExcRecord
{
private:
XclExpString sUsername;
DateTime aDateTime;
sal_uInt8 aGUID[ 16 ];
virtual void SaveCont( XclExpStream& rStrm );
public:
inline XclExpChTrInfo(
const String& rUsername,
const DateTime& rDateTime,
const sal_uInt8* pGUID );
virtual ~XclExpChTrInfo();
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
inline XclExpChTrInfo::XclExpChTrInfo( const String& rUsername, const DateTime& rDateTime, const sal_uInt8* pGUID ) :
sUsername( rUsername ),
aDateTime( rDateTime )
{
memcpy( aGUID, pGUID, 16 );
}
//___________________________________________________________________
// XclExpChTrTabIdBuffer - buffer for tab id's
class XclExpChTrTabIdBuffer
{
private:
sal_uInt16* pBuffer;
sal_uInt16* pLast;
sal_uInt16 nBufSize;
sal_uInt16 nLastId;
public:
XclExpChTrTabIdBuffer( sal_uInt16 nCount );
XclExpChTrTabIdBuffer( const XclExpChTrTabIdBuffer& rCopy );
~XclExpChTrTabIdBuffer();
void InitFill( sal_uInt16 nIndex );
void InitFillup();
sal_uInt16 GetId( sal_uInt16 nIndex ) const;
void Remove();
inline sal_uInt16 GetBufferCount() const
{ return static_cast< sal_uInt16 >( (pLast - pBuffer) + 1 ); }
inline void GetBufferCopy( sal_uInt16* pDest ) const
{ memcpy( pDest, pBuffer, sizeof(sal_uInt16) * GetBufferCount() ); }
};
//___________________________________________________________________
// XclExpChTrTabIdBufferList
class XclExpChTrTabIdBufferList : private List
{
private:
inline XclExpChTrTabIdBuffer* First() { return (XclExpChTrTabIdBuffer*) List::First(); }
inline XclExpChTrTabIdBuffer* Next() { return (XclExpChTrTabIdBuffer*) List::Next(); }
public:
virtual ~XclExpChTrTabIdBufferList();
inline void Append( XclExpChTrTabIdBuffer* pNew )
{ List::Insert( pNew, LIST_APPEND ); }
};
//___________________________________________________________________
// XclExpChTrTabId - tab id record
class XclExpChTrTabId : public ExcRecord
{
private:
sal_uInt16* pBuffer;
sal_uInt16 nTabCount;
inline void Clear() { if( pBuffer ) delete[] pBuffer; pBuffer = NULL; }
virtual void SaveCont( XclExpStream& rStrm );
public:
inline XclExpChTrTabId( sal_uInt16 nCount ) :
pBuffer( NULL ), nTabCount( nCount ) {}
XclExpChTrTabId( const XclExpChTrTabIdBuffer& rBuffer );
virtual ~XclExpChTrTabId();
void Copy( const XclExpChTrTabIdBuffer& rBuffer );
virtual UINT16 GetNum() const;
virtual sal_Size GetLen() const;
};
//___________________________________________________________________
// XclExpChTrAction - base class for action records
class XclExpChTrAction : public ExcRecord
{
private:
String sUsername;
DateTime aDateTime;
sal_uInt32 nIndex; // action number
XclExpChTrAction* pAddAction; // additional record for this action
sal_Bool bAccepted;
protected:
const XclExpTabInfo& rTabInfo; // for table num export (sc num -> xcl num)
const XclExpChTrTabIdBuffer& rIdBuffer; // for table num export (xcl num -> tab id)
sal_uInt32 nLength; // this is not the record size
sal_uInt16 nOpCode; // EXC_CHTR_OP_***
sal_Bool bForceInfo;
XclExpChTrAction( const XclExpChTrAction& rCopy );
void SetAddAction( XclExpChTrAction* pAction );
void AddDependentContents(
const ScChangeAction& rAction,
const XclExpRoot& rRoot,
ScChangeTrack& rChangeTrack );
inline void Write2DAddress( XclExpStream& rStrm, const ScAddress& rAddress ) const;
inline void Write2DRange( XclExpStream& rStrm, const ScRange& rRange ) const;
inline void WriteTabId( XclExpStream& rStrm, SCTAB nTabId ) const;
// save header data, call SaveActionData()
virtual void SaveCont( XclExpStream& rStrm );
inline sal_Size GetHeaderByteCount() const { return 12; }
// overload to save action data without header, called by SaveCont()
virtual void SaveActionData( XclExpStream& rStrm ) const = 0;
// overload to get action size without header, called by GetLen()
virtual sal_Size GetActionByteCount() const = 0;
// do something before writing the record
virtual void PrepareSaveAction( XclExpStream& rStrm ) const;
// do something after writing the record
virtual void CompleteSaveAction( XclExpStream& rStrm ) const;
public:
XclExpChTrAction(
const ScChangeAction& rAction,
const XclExpRoot& rRoot,
const XclExpChTrTabIdBuffer& rTabIdBuffer,
sal_uInt16 nNewOpCode = EXC_CHTR_OP_UNKNOWN );
virtual ~XclExpChTrAction();
inline const String& GetUsername() const { return sUsername; }
inline const DateTime& GetDateTime() const { return aDateTime; }
inline const XclExpChTrTabIdBuffer& GetTabIdBuffer() const { return rIdBuffer; }
inline sal_Bool ForceInfoRecord() const { return bForceInfo; }
// set own index & return new index
// could be overloaded to use more indexes per action
virtual void SetIndex( sal_uInt32& rIndex );
virtual void Save( XclExpStream& rStrm );
virtual sal_Size GetLen() const;
};
inline void XclExpChTrAction::Write2DAddress( XclExpStream& rStrm, const ScAddress& rAddress ) const
{
rStrm << (sal_uInt16) rAddress.Row()
<< (sal_uInt16) rAddress.Col();
}
inline void XclExpChTrAction::Write2DRange( XclExpStream& rStrm, const ScRange& rRange ) const
{
rStrm << (sal_uInt16) rRange.aStart.Row()
<< (sal_uInt16) rRange.aEnd.Row()
<< (sal_uInt16) rRange.aStart.Col()
<< (sal_uInt16) rRange.aEnd.Col();
}
inline void XclExpChTrAction::WriteTabId( XclExpStream& rStrm, SCTAB nTab ) const
{
rStrm << rIdBuffer.GetId( rTabInfo.GetXclTab( nTab ) );
}
//___________________________________________________________________
// XclExpChTrData - cell content itself
struct XclExpChTrData
{
XclExpString* pString;
XclTokenArrayRef mxTokArr;
XclExpRefLog maRefLog;
double fValue;
sal_Int32 nRKValue;
sal_uInt16 nType;
sal_Size nSize;
XclExpChTrData();
~XclExpChTrData();
void Clear();
void WriteFormula(
XclExpStream& rStrm,
const XclExpChTrTabIdBuffer& rTabIdBuffer );
void Write(
XclExpStream& rStrm,
const XclExpChTrTabIdBuffer& rTabIdBuffer );
};
//___________________________________________________________________
// XclExpChTrCellContent - changed cell content
class XclExpChTrCellContent : public XclExpChTrAction, protected XclExpRoot
{
private:
XclExpChTrData* pOldData;
XclExpChTrData* pNewData;
sal_uInt16 nOldLength; // this is not the record size
void MakeEmptyChTrData( XclExpChTrData*& rpData );
protected:
ScAddress aPosition;
void GetCellData(
const ScBaseCell* pScCell,
XclExpChTrData*& rpData,
sal_uInt32& rXclLength1,
sal_uInt16& rXclLength2 );
virtual void SaveActionData( XclExpStream& rStrm ) const;
public:
XclExpChTrCellContent(
const ScChangeActionContent& rAction,
const XclExpRoot& rRoot,
const XclExpChTrTabIdBuffer& rTabIdBuffer );
virtual ~XclExpChTrCellContent();
virtual UINT16 GetNum() const;
virtual sal_Size GetActionByteCount() const;
};
//___________________________________________________________________
// XclExpChTrInsert - insert/delete columns/rows
class XclExpChTrInsert : public XclExpChTrAction
{
protected:
ScRange aRange;
XclExpChTrInsert( const XclExpChTrInsert& rCopy ) :
XclExpChTrAction( rCopy ), aRange( rCopy.aRange ) {}
virtual void SaveActionData( XclExpStream& rStrm ) const;
virtual void PrepareSaveAction( XclExpStream& rStrm ) const;
virtual void CompleteSaveAction( XclExpStream& rStrm ) const;
public:
XclExpChTrInsert(
const ScChangeAction& rAction,
const XclExpRoot& rRoot,
const XclExpChTrTabIdBuffer& rTabIdBuffer,
ScChangeTrack& rChangeTrack );
virtual ~XclExpChTrInsert();
virtual UINT16 GetNum() const;
virtual sal_Size GetActionByteCount() const;
};
//___________________________________________________________________
// XclExpChTrInsertTab - insert table
class XclExpChTrInsertTab : public XclExpChTrAction, protected XclExpRoot
{
private:
SCTAB nTab;
protected:
virtual void SaveActionData( XclExpStream& rStrm ) const;
public:
XclExpChTrInsertTab(
const ScChangeAction& rAction,
const XclExpRoot& rRoot,
const XclExpChTrTabIdBuffer& rTabIdBuffer );
virtual ~XclExpChTrInsertTab();
virtual UINT16 GetNum() const;
virtual sal_Size GetActionByteCount() const;
};
//___________________________________________________________________
// XclExpChTrMoveRange - move cell range
class XclExpChTrMoveRange : public XclExpChTrAction
{
protected:
ScRange aSourceRange;
ScRange aDestRange;
virtual void SaveActionData( XclExpStream& rStrm ) const;
virtual void PrepareSaveAction( XclExpStream& rStrm ) const;
virtual void CompleteSaveAction( XclExpStream& rStrm ) const;
public:
XclExpChTrMoveRange(
const ScChangeActionMove& rAction,
const XclExpRoot& rRoot,
const XclExpChTrTabIdBuffer& rTabIdBuffer,
ScChangeTrack& rChangeTrack );
virtual ~XclExpChTrMoveRange();
virtual UINT16 GetNum() const;
virtual sal_Size GetActionByteCount() const;
};
//___________________________________________________________________
// XclExpChTr0x019A - additional data for delete action
class XclExpChTr0x014A : public XclExpChTrInsert
{
protected:
virtual void SaveActionData( XclExpStream& rStrm ) const;
public:
XclExpChTr0x014A( const XclExpChTrInsert& rAction );
virtual ~XclExpChTr0x014A();
virtual UINT16 GetNum() const;
virtual sal_Size GetActionByteCount() const;
};
//___________________________________________________________________
// XclExpChTrActionStack - temporary action stack
class XclExpChTrActionStack : private Stack
{
public:
virtual ~XclExpChTrActionStack();
void Push( XclExpChTrAction* pNewRec );
inline XclExpChTrAction* Pop() { return (XclExpChTrAction*) Stack::Pop(); }
private:
using Stack::Push;
};
//___________________________________________________________________
// XclExpChTrRecordList - list of "Revision Log" stream records
class XclExpChTrRecordList : private List
{
private:
inline ExcRecord* First() { return (ExcRecord*) List::First(); }
inline ExcRecord* Next() { return (ExcRecord*) List::Next(); }
public:
virtual ~XclExpChTrRecordList();
using List::Count;
void Append( ExcRecord* pNewRec );
void Save( XclExpStream& rStrm );
};
//___________________________________________________________________
// XclExpChangeTrack - exports the "Revision Log" stream
class XclExpChangeTrack : protected XclExpRoot
{
private:
XclExpChTrRecordList aRecList;
XclExpChTrActionStack aActionStack;
XclExpChTrTabIdBufferList aTabIdBufferList;
XclExpChTrTabIdBuffer* pTabIdBuffer;
ScDocument* pTempDoc; // empty document
sal_uInt32 nNewAction; // action number, 1-based
XclExpChTrHeader* pHeader; // header record for last GUID
sal_uInt8 aGUID[ 16 ]; // GUID for action info records
sal_Bool bValidGUID;
ScChangeTrack* CreateTempChangeTrack();
void PushActionRecord( const ScChangeAction& rAction );
sal_Bool WriteUserNamesStream();
public:
XclExpChangeTrack( const XclExpRoot& rRoot );
~XclExpChangeTrack();
void Write();
};
//___________________________________________________________________
#endif
|