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
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
|
/*************************************************************************
*
* $RCSfile: XclExpChangeTrack.hxx,v $
*
* $Revision: 1.9 $
*
* last change: $Author: dr $ $Date: 2002-11-21 12:20:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef SC_XCLEXPCHANGETRACK_HXX
#define SC_XCLEXPCHANGETRACK_HXX
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _DATETIME_HXX
#include <tools/datetime.hxx>
#endif
#ifndef _RTL_UUID_H_
#include <rtl/uuid.h>
#endif
#ifndef SC_BIGRANGE_HXX
#include "bigrange.hxx"
#endif
#ifndef SC_CHGTRACK_HXX
#include "chgtrack.hxx"
#endif
#ifndef SC_FTOOLS_HXX
#include "ftools.hxx"
#endif
#ifndef SC_XELINK_HXX
#include "xelink.hxx"
#endif
#ifndef _EXCRECDS_HXX
#include "excrecds.hxx"
#endif
//___________________________________________________________________
class ExcUPN;
class ScBaseCell;
//___________________________________________________________________
// XclExpUserBView - one UserBView record for each user
class XclExpUserBView : public ExcRecord
{
private:
XclExpUniString 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 ULONG 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 ULONG 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 ULONG GetLen() const;
};
//___________________________________________________________________
// dummy record for "User Names" stream
class XclExpChTr0x0191 : public ExcRecord
{
private:
virtual void SaveCont( XclExpStream& rStrm );
public:
virtual UINT16 GetNum() const;
virtual ULONG GetLen() const;
};
//___________________________________________________________________
// dummy record for "User Names" stream
class XclExpChTr0x0198 : public ExcRecord
{
private:
virtual void SaveCont( XclExpStream& rStrm );
public:
virtual UINT16 GetNum() const;
virtual ULONG GetLen() const;
};
//___________________________________________________________________
// dummy record for "User Names" stream
class XclExpChTr0x0192 : public ExcRecord
{
private:
virtual void SaveCont( XclExpStream& rStrm );
public:
virtual UINT16 GetNum() const;
virtual ULONG GetLen() const;
};
//___________________________________________________________________
// dummy record for "User Names" stream
class XclExpChTr0x0197 : public ExcRecord
{
private:
virtual void SaveCont( XclExpStream& rStrm );
public:
virtual UINT16 GetNum() const;
virtual ULONG 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 ULONG 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 ULONG GetLen() const;
};
//___________________________________________________________________
// dummy record for "Revision Log" stream
class XclExpChTr0x0194 : public ExcRecord
{
private:
XclExpUniString sUsername;
DateTime aDateTime;
virtual void SaveCont( XclExpStream& rStrm );
public:
inline XclExpChTr0x0194( const ScChangeTrack& rChangeTrack );
virtual ~XclExpChTr0x0194();
virtual UINT16 GetNum() const;
virtual ULONG 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 ULONG GetLen() const;
};
//___________________________________________________________________
// XclExpChTrInfo - header of action group of a user
class XclExpChTrInfo : public ExcRecord
{
private:
XclExpUniString 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 ULONG 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 (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 ULONG 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 XclExpTabIdBuffer& rTabBuffer; // 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,
RootData& rRootData,
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, sal_uInt16 nTabId ) const;
// save header data, call SaveActionData()
virtual void SaveCont( XclExpStream& rStrm );
inline ULONG 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 ULONG 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 RootData& rRootData,
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 ULONG 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, sal_uInt16 nTab ) const
{
rStrm << rIdBuffer.GetId( rTabBuffer.GetXclTab( nTab ) );
}
//___________________________________________________________________
// XclExpChTrData - cell content itself
struct XclExpChTrData
{
XclExpUniString* pString;
ExcUPN* pUPN;
XclExpRefLogVec aRefLog;
double fValue;
sal_Int32 nRKValue;
sal_uInt16 nType;
sal_uInt16 nSize;
inline XclExpChTrData();
inline ~XclExpChTrData() { Clear(); }
void Clear();
void WriteFormula(
XclExpStream& rStrm,
const RootData& rRootData,
const XclExpChTrTabIdBuffer& rTabIdBuffer );
void Write(
XclExpStream& rStrm,
const RootData& rRootData,
const XclExpChTrTabIdBuffer& rTabIdBuffer );
};
inline XclExpChTrData::XclExpChTrData() :
pString( NULL ),
pUPN( NULL ),
fValue( 0.0 ),
nRKValue( 0 ),
nType( EXC_CHTR_TYPE_EMPTY ),
nSize( 0 )
{
}
//___________________________________________________________________
// XclExpChTrCellContent - changed cell content
class XclExpChTrCellContent : public XclExpChTrAction, private ExcRoot
{
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,
RootData& rRootData,
const XclExpChTrTabIdBuffer& rTabIdBuffer );
virtual ~XclExpChTrCellContent();
virtual UINT16 GetNum() const;
virtual ULONG 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,
RootData& rRootData,
const XclExpChTrTabIdBuffer& rTabIdBuffer,
ScChangeTrack& rChangeTrack );
virtual ~XclExpChTrInsert();
virtual UINT16 GetNum() const;
virtual ULONG GetActionByteCount() const;
};
//___________________________________________________________________
// XclExpChTrInsertTab - insert table
class XclExpChTrInsertTab : public XclExpChTrAction, private ExcRoot
{
private:
sal_uInt16 nTab;
protected:
virtual void SaveActionData( XclExpStream& rStrm ) const;
public:
XclExpChTrInsertTab(
const ScChangeAction& rAction,
RootData& rRootData,
const XclExpChTrTabIdBuffer& rTabIdBuffer );
virtual ~XclExpChTrInsertTab();
virtual UINT16 GetNum() const;
virtual ULONG 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,
RootData& rRootData,
const XclExpChTrTabIdBuffer& rTabIdBuffer,
ScChangeTrack& rChangeTrack );
virtual ~XclExpChTrMoveRange();
virtual UINT16 GetNum() const;
virtual ULONG 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 ULONG GetActionByteCount() const;
};
//___________________________________________________________________
// XclExpChTrActionStack - temporary action stack
class XclExpChTrActionStack : private Stack
{
public:
virtual ~XclExpChTrActionStack();
void Push( XclExpChTrAction* pNewRec );
inline XclExpChTrAction* Pop() { return (XclExpChTrAction*) Stack::Pop(); }
};
//___________________________________________________________________
// 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();
List::Count;
void Append( ExcRecord* pNewRec );
void Save( XclExpStream& rStrm );
};
//___________________________________________________________________
// XclExpChangeTrack - exports the "Revision Log" stream
class XclExpChangeTrack : private ExcRoot
{
private:
XclExpChTrRecordList aRecList;
XclExpChTrActionStack aActionStack;
XclExpChTrTabIdBufferList aTabIdBufferList;
XclExpChTrTabIdBuffer* pTabIdBuffer;
ScDocument* pTempDoc; // empty document
ScChangeTrack* pTempChangeTrack; // copy of <pOrigChangeTrack>
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;
sal_Bool CreateTempChangeTrack();
void PushActionRecord( const ScChangeAction& rAction );
sal_Bool WriteUserNamesStream();
public:
XclExpChangeTrack( RootData* pRootData );
~XclExpChangeTrack();
void Write();
};
//___________________________________________________________________
#endif
|