summaryrefslogtreecommitdiff
path: root/patches/src680/sc-dp-gridlayout.diff
blob: 021785e7b944bfd3d26c2eec371716695e83569a (plain)
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
diff -rup sc/inc/attrib.hxx sc/inc/attrib.hxx
--- sc/inc/attrib.hxx	2005-09-08 13:23:08.000000000 -0400
+++ sc/inc/attrib.hxx	2006-10-31 05:42:56.000000000 -0500
@@ -225,15 +225,15 @@ private:
 	USHORT	nFlags;
 };
 
-inline ScRangeItem::ScRangeItem( const USHORT nWhich )
-	:	SfxPoolItem( nWhich ), nFlags( SCR_INVALID ) // == ungueltige Area
+inline ScRangeItem::ScRangeItem( const USHORT nWhichP )
+	:	SfxPoolItem( nWhichP ), nFlags( SCR_INVALID ) // == ungueltige Area
 {
 }
 
-inline ScRangeItem::ScRangeItem( const USHORT	nWhich,
+inline ScRangeItem::ScRangeItem( const USHORT	nWhichP,
 								 const ScRange& rRange,
 								 const USHORT	nNew )
-	: SfxPoolItem( nWhich ), aRange( rRange ), nFlags( nNew )
+	: SfxPoolItem( nWhichP ), aRange( rRange ), nFlags( nNew )
 {
 }
 
@@ -281,8 +281,8 @@ public:
 	SCTAB*  pTabArr;
 };
 
-inline ScTableListItem::ScTableListItem( const USHORT nWhich )
-	: SfxPoolItem(nWhich), nCount(0), pTabArr(NULL)
+inline ScTableListItem::ScTableListItem( const USHORT nWhichP )
+	: SfxPoolItem(nWhichP), nCount(0), pTabArr(NULL)
 {}
 
 //----------------------------------------------------------------------------
diff -rup sc/inc/dpobject.hxx sc/inc/dpobject.hxx
--- sc/inc/dpobject.hxx	2006-10-30 10:45:07.000000000 -0500
+++ sc/inc/dpobject.hxx	2006-11-01 12:09:52.000000000 -0500
@@ -119,7 +119,8 @@ private:
 	ScDPOutput*				pOutput;
 	BOOL					bSettingsChanged;
 	BOOL					bAlive;			// FALSE if only used to hold settings
-	USHORT                                  nAutoFormatIndex;
+	USHORT                  nAutoFormatIndex;
+	BOOL 			        bHeaderLayout;	// TRUE : grid, FALSE : standard
 	BOOL					bAllowMove;
 	BOOL					bInfoValid;		// affects: nHeaderRows
 	long					nHeaderRows;	// page fields plus filter button
@@ -153,6 +154,9 @@ public:
 	void 			SetAutoFormatIndex (const USHORT nIndex);
 	const USHORT		GetAutoFormatIndex ()	{ if (this == NULL) return 65535; else return nAutoFormatIndex; }
 
+	void 			    SetHeaderLayout (BOOL bUseGrid);
+	BOOL			    GetHeaderLayout ()	const { return bHeaderLayout; }
+
 	void				SetSheetDesc(const ScSheetSourceDesc& rDesc);
 	void				SetImportDesc(const ScImportSourceDesc& rDesc);
 	void				SetServiceData(const ScDPServiceDesc& rDesc);
diff -rup sc/inc/dpoutput.hxx sc/inc/dpoutput.hxx
--- sc/inc/dpoutput.hxx	2006-10-30 10:45:07.000000000 -0500
+++ sc/inc/dpoutput.hxx	2006-11-01 12:10:01.000000000 -0500
@@ -123,6 +123,7 @@ private:
 	long					nColCount;
 	long					nRowCount;
 	long					nHeaderSize;
+	BOOL 			        bHeaderLayout;	// TRUE : grid, FALSE : standard
 	SCCOL					nTabStartCol;
 	SCROW					nTabStartRow;
 	SCCOL					nMemberStartCol;
@@ -165,6 +166,9 @@ public:
 	BOOL			IsFilterButton( const ScAddress& rPos );
 
     void            GetMemberResultNames( StrCollection& rNames, long nDimension );
+
+	void 			SetHeaderLayout (BOOL bUseGrid);
+	BOOL			GetHeaderLayout () const 	{ return bHeaderLayout; }
 };
 
 
diff -rup sc/inc/patattr.hxx sc/inc/patattr.hxx
--- sc/inc/patattr.hxx	2005-09-08 13:48:10.000000000 -0400
+++ sc/inc/patattr.hxx	2006-10-31 05:42:27.000000000 -0500
@@ -97,8 +97,8 @@ public:
 
 	virtual int 			operator==(const SfxPoolItem& rCmp) const;
 
-	const SfxPoolItem&      GetItem( USHORT nWhich ) const
-										{ return GetItemSet().Get(nWhich); }
+	const SfxPoolItem&      GetItem( USHORT nWhichP ) const
+										{ return GetItemSet().Get(nWhichP); }
 
     static const SfxPoolItem& GetItem( USHORT nWhich, const SfxItemSet& rItemSet, const SfxItemSet* pCondSet );
 	const SfxPoolItem&		GetItem( USHORT nWhich, const SfxItemSet* pCondSet ) const;
diff -rup sc/inc/rangenam.hxx sc/inc/rangenam.hxx
--- sc/inc/rangenam.hxx	2006-07-10 09:23:26.000000000 -0400
+++ sc/inc/rangenam.hxx	2006-10-31 05:44:40.000000000 -0500
@@ -207,8 +207,8 @@ public:
 
 	ScRangeName(const ScRangeName& rScRangeName, ScDocument* pDocument);
 
-	virtual	DataObject* 	Clone(ScDocument* pDoc) const
-							 { return new ScRangeName(*this, pDoc); }
+	virtual	DataObject* 	Clone(ScDocument* pDocP) const
+							 { return new ScRangeName(*this, pDocP); }
 	ScRangeData*			operator[]( const USHORT nIndex) const
 							 { return (ScRangeData*)At(nIndex); }
 	virtual	short			Compare(DataObject* pKey1, DataObject* pKey2) const;
diff -rup sc/source/core/data/dpobject.cxx sc/source/core/data/dpobject.cxx
--- sc/source/core/data/dpobject.cxx	2006-10-30 10:45:07.000000000 -0500
+++ sc/source/core/data/dpobject.cxx	2006-11-01 11:02:16.000000000 -0500
@@ -156,6 +156,7 @@ ScDPObject::ScDPObject( ScDocument* pD )
 	pServDesc( NULL ),
 	pOutput( NULL ),
 	nAutoFormatIndex(65535),
+	bHeaderLayout(FALSE),
 	bSettingsChanged( FALSE )
 {
 }
@@ -171,6 +172,7 @@ ScDPObject::ScDPObject(const ScDPObject&
 	aTableTag( r.aTableTag ),
 	aOutRange( r.aOutRange ),
 	nAutoFormatIndex(r.nAutoFormatIndex),
+	bHeaderLayout(r.bHeaderLayout),
 	pSheetDesc( NULL ),
 	pImpDesc( NULL ),
 	pServDesc( NULL ),
@@ -228,6 +230,11 @@ void ScDPObject::SetAutoFormatIndex(cons
 	nAutoFormatIndex	= nIndex;
 }
 
+void ScDPObject::SetHeaderLayout (BOOL bUseGrid)
+{
+	bHeaderLayout = bUseGrid;
+}
+
 void ScDPObject::SetOutRange(const ScRange& rRange)
 {
 	aOutRange = rRange;
@@ -335,6 +342,7 @@ void ScDPObject::CreateOutput()
 	{
         BOOL bFilterButton = IsSheetData() && pSaveData && pSaveData->GetFilterButton();
         pOutput = new ScDPOutput( pDoc, xSource, aOutRange.aStart, bFilterButton );
+		pOutput->SetHeaderLayout ( bHeaderLayout );
 
 		long nOldRows = nHeaderRows;
 		nHeaderRows = pOutput->GetHeaderRows();
diff -rup sc/source/core/data/dpoutput.cxx sc/source/core/data/dpoutput.cxx
--- sc/source/core/data/dpoutput.cxx	2006-10-30 10:45:07.000000000 -0500
+++ sc/source/core/data/dpoutput.cxx	2006-11-01 10:11:45.000000000 -0500
@@ -364,7 +364,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, 
 	pRowNumFmt( NULL ),
 	nColFmtCount( 0 ),
 	nRowFmtCount( 0 ),
-    nSingleNumFmt( 0 )
+    nSingleNumFmt( 0 ),
+	bHeaderLayout( FALSE )
 {
 	nTabStartCol = nMemberStartCol = nDataStartCol = nTabEndCol = 0;
 	nTabStartRow = nMemberStartRow = nDataStartRow = nTabEndRow = 0;
@@ -652,7 +653,8 @@ void ScDPOutput::CalcSizes()
 		nRowCount = aData.getLength();
 		const uno::Sequence<sheet::DataResult>* pRowAry = aData.getConstArray();
 		nColCount = nRowCount ? ( pRowAry[0].getLength() ) : 0;
-		nHeaderSize = 1;			// one row for field names
+
+		nHeaderSize = GetHeaderLayout () ? 2 : 1;
 
 		//	calculate output positions and sizes
 
@@ -918,6 +920,12 @@ void ScDPOutput::GetMemberResultNames( S
     }
 }
 
+void ScDPOutput::SetHeaderLayout (BOOL bLayout)
+{
+	bHeaderLayout = bLayout;
+	bSizesValid = FALSE;
+}
+
 //
 //		Methods to find specific parts of the table
 //
diff -rup sc/source/filter/excel/read.cxx sc/source/filter/excel/read.cxx
--- sc/source/filter/excel/read.cxx	2006-10-30 15:28:16.000000000 -0500
+++ sc/source/filter/excel/read.cxx	2006-10-30 17:32:24.000000000 -0500
@@ -1200,6 +1200,7 @@ FltError ImportExcel8::Read( void )
                     case EXC_ID_SXDI:           rPTableMgr.ReadSxdi( maStrm );      break;
                     case EXC_ID_SXVDEX:         rPTableMgr.ReadSxvdex( maStrm );    break;
                     case EXC_ID_SXEX:           rPTableMgr.ReadSxex( maStrm );      break;
+                    case EXC_ID_SX_AUTOFORMAT:  rPTableMgr.ReadSxAutoformat( maStrm ); break;
                 }
 			}
             break;
diff -rup sc/source/filter/excel/xepivot.cxx sc/source/filter/excel/xepivot.cxx
--- sc/source/filter/excel/xepivot.cxx	2006-10-30 10:45:07.000000000 -0500
+++ sc/source/filter/excel/xepivot.cxx	2006-11-02 09:47:08.000000000 -0500
@@ -1260,6 +1260,8 @@ XclExpPivotTable::XclExpPivotTable( cons
         maPTInfo.maDataName = ScGlobal::GetRscString( STR_PIVOT_DATA );
         maPTInfo.mnCacheIdx = mrPCache.GetCacheIndex();
 
+		maPTAutoFormat.Init( rDPObj );
+
         if( const ScDPSaveData* pSaveData = rDPObj.GetSaveData() )
         {
             // additional properties from ScDPSaveData
@@ -1339,6 +1341,8 @@ void XclExpPivotTable::Save( XclExpStrea
         WriteSxli( rStrm, maPTInfo.mnDataCols, maPTInfo.mnColFields );
         // SXEX
         WriteSxex( rStrm );
+		// SX_AUTOFORMAT
+		WriteSxAutoformat( rStrm );
     }
 }
 
@@ -1478,6 +1482,8 @@ void XclExpPivotTable::Finalize()
     rnDataXclRow = rnXclRow1 + maPTInfo.mnColFields + 1;
     if( maDataFields.empty() )
         ++rnDataXclRow;
+    if( 0 == maPTAutoFormat.mbGridLayout )
+        ++rnDataXclRow;
     rnXclCol2 = ::std::max( rnXclCol2, rnDataXclCol );
     rnXclRow2 = ::std::max( rnXclRow2, rnDataXclRow );
     maPTInfo.mnDataCols = rnXclCol2 - rnDataXclCol + 1;
@@ -1485,6 +1491,8 @@ void XclExpPivotTable::Finalize()
 
     // first heading
     maPTInfo.mnFirstHeadRow = rnXclRow1 + 1;
+    if( 0 == maPTAutoFormat.mbGridLayout )
+		maPTInfo.mnFirstHeadRow++;
 }
 
 // records ----------------------------------------------------------------
@@ -1560,6 +1568,18 @@ void XclExpPivotTable::WriteSxex( XclExp
     rStrm.EndRecord();
 }
 
+void XclExpPivotTable::WriteSxAutoformat( XclExpStream& rStrm ) const
+{
+	// Until we sync the autoformat ids only export if using grid header layout
+	// That could only have been set via xls import so far.
+	if( 0 == maPTAutoFormat.mbGridLayout )
+	{
+		rStrm.StartRecord( EXC_ID_SX_AUTOFORMAT, 17 );
+		rStrm << maPTAutoFormat;
+		rStrm.EndRecord();
+	}
+}
+
 // ============================================================================
 
 namespace {
diff -rup sc/source/filter/excel/xipivot.cxx sc/source/filter/excel/xipivot.cxx
--- sc/source/filter/excel/xipivot.cxx	2006-10-30 10:45:07.000000000 -0500
+++ sc/source/filter/excel/xipivot.cxx	2006-11-01 11:20:35.000000000 -0500
@@ -1157,6 +1157,11 @@ void XclImpPivotTable::ReadSxex( XclImpS
     rStrm >> maPTExtInfo;
 }
 
+void XclImpPivotTable::ReadSxAutoformat( XclImpStream& rStrm )
+{
+    rStrm >> maPTAutoFormat;
+}
+
 // ----------------------------------------------------------------------------
 
 void XclImpPivotTable::Apply() const
@@ -1231,6 +1236,7 @@ void XclImpPivotTable::Apply() const
     pDPObj->SetSheetDesc( aDesc );
     pDPObj->SetOutRange( aOutRange );
     pDPObj->SetAlive( TRUE );
+	pDPObj->SetHeaderLayout( maPTAutoFormat.mbGridLayout == 0 );
     GetDoc().GetDPCollection()->Insert( pDPObj );
     if( pDPObj )
     {
@@ -1333,6 +1339,12 @@ void XclImpPivotTableManager::ReadSxex( 
         maPTableList.Last()->ReadSxex( rStrm );
 }
 
+void XclImpPivotTableManager::ReadSxAutoformat( XclImpStream& rStrm )
+{
+    if( !maPTableList.Empty() )
+        maPTableList.Last()->ReadSxAutoformat( rStrm );
+}
+
 // ----------------------------------------------------------------------------
 
 void XclImpPivotTableManager::Apply() const
diff -rup sc/source/filter/excel/xlpivot.cxx sc/source/filter/excel/xlpivot.cxx
--- sc/source/filter/excel/xlpivot.cxx	2006-07-21 08:20:15.000000000 -0400
+++ sc/source/filter/excel/xlpivot.cxx	2006-11-01 11:52:53.000000000 -0500
@@ -332,8 +332,8 @@ XclExpStream& operator<<( XclExpStream& 
 // Base class for pivot cache fields ==========================================
 
 XclPCField::XclPCField( XclPCFieldType eFieldType, sal_uInt16 nFieldIdx ) :
-    mnFieldIdx( nFieldIdx ),
-    meFieldType( eFieldType )
+    meFieldType( eFieldType ),
+    mnFieldIdx( nFieldIdx )
 {
 }
 
@@ -533,6 +533,7 @@ void XclPTFieldInfo::AddApiOrient( DataP
     using namespace ::com::sun::star::sheet;
     switch( eOrient )
     {
+		default: break;
         case DataPilotFieldOrientation_ROW:     mnAxes |= EXC_SXVD_AXIS_ROW;    break;
         case DataPilotFieldOrientation_COLUMN:  mnAxes |= EXC_SXVD_AXIS_COL;    break;
         case DataPilotFieldOrientation_PAGE:    mnAxes |= EXC_SXVD_AXIS_PAGE;   break;
@@ -960,3 +961,79 @@ XclExpStream& operator<<( XclExpStream& 
 
 // ============================================================================
 
+// Pivot table autoformat settings ============================================
+
+/**
+classic		: 10 08 00 00 00 00 00 00 20 00 00 00 01 00 00 00 00
+default		: 10 08 00 00 00 00 00 00 20 00 00 00 01 00 00 00 00
+report01	: 10 08 02 00 00 00 00 00 20 00 00 00 00 10 00 00 00
+report02	: 10 08 02 00 00 00 00 00 20 00 00 00 01 10 00 00 00
+report03	: 10 08 02 00 00 00 00 00 20 00 00 00 02 10 00 00 00
+report04	: 10 08 02 00 00 00 00 00 20 00 00 00 03 10 00 00 00
+report05	: 10 08 02 00 00 00 00 00 20 00 00 00 04 10 00 00 00
+report06	: 10 08 02 00 00 00 00 00 20 00 00 00 05 10 00 00 00
+report07	: 10 08 02 00 00 00 00 00 20 00 00 00 06 10 00 00 00
+report08	: 10 08 02 00 00 00 00 00 20 00 00 00 07 10 00 00 00
+report09	: 10 08 02 00 00 00 00 00 20 00 00 00 08 10 00 00 00
+report10	: 10 08 02 00 00 00 00 00 20 00 00 00 09 10 00 00 00
+table01		: 10 08 00 00 00 00 00 00 20 00 00 00 0a 10 00 00 00
+table02		: 10 08 00 00 00 00 00 00 20 00 00 00 0b 10 00 00 00
+table03		: 10 08 00 00 00 00 00 00 20 00 00 00 0c 10 00 00 00
+table04		: 10 08 00 00 00 00 00 00 20 00 00 00 0d 10 00 00 00
+table05		: 10 08 00 00 00 00 00 00 20 00 00 00 0e 10 00 00 00
+table06		: 10 08 00 00 00 00 00 00 20 00 00 00 0f 10 00 00 00
+table07		: 10 08 00 00 00 00 00 00 20 00 00 00 10 10 00 00 00
+table08		: 10 08 00 00 00 00 00 00 20 00 00 00 11 10 00 00 00
+table09		: 10 08 00 00 00 00 00 00 20 00 00 00 12 10 00 00 00
+table10		: 10 08 00 00 00 00 00 00 20 00 00 00 13 10 00 00 00
+none		: 10 08 00 00 00 00 00 00 20 00 00 00 15 10 00 00 00
+**/
+
+XclPTAutoFormat::XclPTAutoFormat() :
+    mbReport( 0 ),
+    mnAutoFormat( 0 ),
+    mbGridLayout( 0x10 )
+{
+}
+
+void XclPTAutoFormat::Init( const ScDPObject& rDPObj )
+{
+	if( rDPObj.GetHeaderLayout() )
+	{
+		mbReport 	 = 0;
+		mnAutoFormat = 1;
+		mbGridLayout = 0;
+	}
+	else
+	{
+		// Report1 for now
+		// TODO : sync with autoformat indicies
+		mbReport 	 = 2;
+		mnAutoFormat = 1;
+		mbGridLayout = 0x10;
+	}
+}
+
+XclImpStream& operator>>( XclImpStream& rStrm, XclPTAutoFormat& rInfo )
+{
+    rStrm.Ignore( 2 );
+    rStrm >> rInfo.mbReport;     		/// 2 for report* fmts ?
+    rStrm.Ignore( 6 );
+    return rStrm
+        >> rInfo.mnAutoFormat
+        >> rInfo.mbGridLayout;
+}
+
+XclExpStream& operator<<( XclExpStream& rStrm, const XclPTAutoFormat& rInfo )
+{
+    return rStrm
+        << EXC_PT_AUTOFMT_HEADER
+        << rInfo.mbReport
+		<< EXC_PT_AUTOFMT_ZERO
+        << EXC_PT_AUTOFMT_FLAGS
+        << rInfo.mnAutoFormat
+        << rInfo.mbGridLayout;
+}
+
+// ============================================================================
+
diff -rup sc/source/filter/inc/xepivot.hxx sc/source/filter/inc/xepivot.hxx
--- sc/source/filter/inc/xepivot.hxx	2006-07-10 09:55:31.000000000 -0400
+++ sc/source/filter/inc/xepivot.hxx	2006-11-01 11:26:54.000000000 -0500
@@ -421,6 +421,8 @@ private:
     void                WriteSxli( XclExpStream& rStrm, sal_uInt16 nLineCount, sal_uInt16 nIndexCount ) const;
     /** Writes the SXEX records containing additional pivot table info. */
     void                WriteSxex( XclExpStream& rStrm ) const;
+    /** Writes the SX_AUTOFORMAT records with the autoformat id and header layout */
+    void                WriteSxAutoformat( XclExpStream& rStrm ) const;
 
     // ------------------------------------------------------------------------
 private:
@@ -431,6 +433,7 @@ private:
     const XclExpPivotCache& mrPCache;       /// The pivot cache this pivot table bases on.
     XclPTInfo           maPTInfo;           /// Info about the pivot table (SXVIEW record).
     XclPTExtInfo        maPTExtInfo;        /// Extended info about the pivot table (SXEX record).
+	XclPTAutoFormat		maPTAutoFormat;		/// The selected autoformat (SX_AUTOFORMAT)
     XclExpPTFieldList   maFieldList;        /// All fields in pivot cache order.
     ScfUInt16Vec        maRowFields;        /// Row field indexes.
     ScfUInt16Vec        maColFields;        /// Column field indexes.
diff -rup sc/source/filter/inc/xipivot.hxx sc/source/filter/inc/xipivot.hxx
--- sc/source/filter/inc/xipivot.hxx	2006-07-10 09:59:59.000000000 -0400
+++ sc/source/filter/inc/xipivot.hxx	2006-10-31 06:50:03.000000000 -0500
@@ -343,6 +343,8 @@ public:
     void                ReadSxdi( XclImpStream& rStrm );
     /** Reads an SXEX record containing additional settings for the pivot table. */
     void                ReadSxex( XclImpStream& rStrm );
+    /** Reads an SX_AUTOFORMAT record that specifies the pivot tables autoformat. */
+    void                ReadSxAutoformat( XclImpStream& rStrm );
 
     // ------------------------------------------------------------------------
 
@@ -357,6 +359,7 @@ private:
 
     XclPTInfo           maPTInfo;           /// General info about the pivot table (SXVIEW record).
     XclPTExtInfo        maPTExtInfo;        /// Extended info about the pivot table (SXEX record).
+	XclPTAutoFormat		maPTAutoFormat;		/// The selected autoformat (SX_AUTOFORMAT)
     XclImpPTFieldList   maFieldList;        /// List containing all fields.
     ScfStringVec        maVisFieldNames;    /// Vector containing all visible field names.
     ScfUInt16Vec        maRowFields;        /// Row field indexes.
@@ -417,6 +420,8 @@ public:
     void                ReadSxvi( XclImpStream& rStrm );
     /** Reads an SXEX record containing additional settings for a pivot table. */
     void                ReadSxex( XclImpStream& rStrm );
+    /** Reads an SX_AUTOFORMAT record that specifies the pivot tables autoformat. */
+    void                ReadSxAutoformat( XclImpStream& rStrm );
 
     // ------------------------------------------------------------------------
 
diff -rup sc/source/filter/inc/xlpivot.hxx sc/source/filter/inc/xlpivot.hxx
--- sc/source/filter/inc/xlpivot.hxx	2006-10-18 07:46:00.000000000 -0400
+++ sc/source/filter/inc/xlpivot.hxx	2006-11-01 12:06:03.000000000 -0500
@@ -63,6 +63,9 @@
 #ifndef SC_XLADDRESS_HXX
 #include "xladdress.hxx"
 #endif
+#ifndef SC_DPOBJECT_HXX
+#include "dpobject.hxx"
+#endif
 
 class XclImpStream;
 class XclExpStream;
@@ -94,6 +97,10 @@ const sal_uInt16 EXC_PT_MAXDATACOUNT    
 // pivot table items
 const sal_uInt16 EXC_PT_MAXITEMCOUNT        = 32500;
 
+const sal_uInt16 EXC_PT_AUTOFMT_HEADER      = 0x810;
+const sal_uInt16 EXC_PT_AUTOFMT_ZERO        = 0;
+const sal_uInt32 EXC_PT_AUTOFMT_FLAGS       = 0x20;
+
 /** Data type of a pivot cache item. */
 enum XclPCItemType
 {
@@ -412,6 +419,9 @@ const double EXC_SXDBEX_CREATION_DATE   
 const sal_uInt16 EXC_ID_SXFDBTYPE           = 0x01BB;
 const sal_uInt16 EXC_SXFDBTYPE_DEFAULT      = 0x0000;
 
+// (0x0810) PIVOT_AUTOFORMAT	// 2006/10/17 JEG no docs, but seems to contain the autoformat
+const sal_uInt16 EXC_ID_SX_AUTOFORMAT       = 0x0810;
+
 // ============================================================================
 // Pivot cache
 // ============================================================================
@@ -798,5 +808,22 @@ XclExpStream& operator<<( XclExpStream& 
 
 // ============================================================================
 
+// Pivot table autoformat settings ==============================================
+
+/** Pivot table autoformat settings (SX_AUTOFORMAT record). */
+struct XclPTAutoFormat
+{
+    sal_uInt32          mbReport;     		/// 2 for report* fmts ?
+    sal_uInt8           mnAutoFormat;       /// AutoFormat ID
+    sal_uInt32          mbGridLayout;       /// 0 == gridlayout, 0x10 == modern
+
+    explicit            XclPTAutoFormat();
+	void				Init( const ScDPObject& rDPObj );
+};
+
+XclImpStream& operator>>( XclImpStream& rStrm, XclPTAutoFormat& rInfo );
+XclExpStream& operator<<( XclExpStream& rStrm, const XclPTAutoFormat& rInfo );
+
+// ============================================================================
 #endif
 
diff -rup sc/source/filter/xml/XMLExportDataPilot.cxx sc/source/filter/xml/XMLExportDataPilot.cxx
--- sc/source/filter/xml/XMLExportDataPilot.cxx	2006-10-30 10:45:07.000000000 -0500
+++ sc/source/filter/xml/XMLExportDataPilot.cxx	2006-11-01 16:30:11.000000000 -0500
@@ -851,6 +851,8 @@ void ScXMLExportDataPilot::WriteDataPilo
                             rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SHOW_FILTER_BUTTON, XML_FALSE);
                         if (!pDPSave->GetDrillDown())
                             rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DRILL_DOWN_ON_DOUBLE_CLICK, XML_FALSE);
+						if ((*pDPs)[i]->GetHeaderLayout ())
+                            rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_HEADER_GRID_LAYOUT, XML_TRUE);
 						SvXMLElementExport aElemDP(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLE, sal_True, sal_True);
 						rExport.CheckAttrList();
 						if ((*pDPs)[i]->IsSheetData())
diff -rup sc/source/filter/xml/xmldpimp.cxx sc/source/filter/xml/xmldpimp.cxx
--- sc/source/filter/xml/xmldpimp.cxx	2006-07-21 08:52:13.000000000 -0400
+++ sc/source/filter/xml/xmldpimp.cxx	2006-11-01 16:15:47.000000000 -0500
@@ -158,6 +158,7 @@ ScXMLDataPilotTableContext::ScXMLDataPil
 	bSourceCellRange(sal_False),
     bShowFilter(sal_True),
     bDrillDown(sal_True),
+	bHeaderGridLayout(sal_False),
 	pDoc(GetScImport().GetDocument()),
 	pDPObject(NULL),
 	pDPSave(NULL),
@@ -221,6 +222,11 @@ ScXMLDataPilotTableContext::ScXMLDataPil
                 bDrillDown = IsXMLToken(sValue, XML_TRUE);
             }
             break;
+			case XML_TOK_DATA_PILOT_TABLE_ATTR_HEADER_GRID_LAYOUT :
+			{
+				bHeaderGridLayout = IsXMLToken(sValue, XML_TRUE);
+			}
+            break;
 		}
 	}
 
@@ -342,6 +348,7 @@ void ScXMLDataPilotTableContext::EndElem
 		pDPObject->SetName(sDataPilotTableName);
 		pDPObject->SetTag(sApplicationData);
 		pDPObject->SetOutRange(aTargetRangeAddress);
+		pDPObject->SetHeaderLayout(bHeaderGridLayout);
 		switch (nSourceType)
 		{
 			case SQL :
diff -rup sc/source/filter/xml/xmldpimp.hxx sc/source/filter/xml/xmldpimp.hxx
--- sc/source/filter/xml/xmldpimp.hxx	2005-10-25 07:00:50.000000000 -0400
+++ sc/source/filter/xml/xmldpimp.hxx	2006-11-01 15:37:02.000000000 -0500
@@ -129,6 +129,7 @@ class ScXMLDataPilotTableContext : publi
 	sal_Bool		bSourceCellRange;
     sal_Bool        bShowFilter;
     sal_Bool        bDrillDown;
+	sal_Bool		bHeaderGridLayout;
 
 	const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
 	ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
diff -rup sc/source/filter/xml/xmlimprt.cxx sc/source/filter/xml/xmlimprt.cxx
--- sc/source/filter/xml/xmlimprt.cxx	2006-07-21 08:53:26.000000000 -0400
+++ sc/source/filter/xml/xmlimprt.cxx	2006-11-01 16:17:43.000000000 -0500
@@ -745,6 +745,7 @@ static __FAR_DATA SvXMLTokenMapEntry aDa
 	{ XML_NAMESPACE_TABLE, XML_BUTTONS,				    XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS				},
 	{ XML_NAMESPACE_TABLE, XML_SHOW_FILTER_BUTTON,	    XML_TOK_DATA_PILOT_TABLE_ATTR_SHOW_FILTER_BUTTON	},
 	{ XML_NAMESPACE_TABLE, XML_DRILL_DOWN_ON_DOUBLE_CLICK, XML_TOK_DATA_PILOT_TABLE_ATTR_DRILL_DOWN			},
+	{ XML_NAMESPACE_TABLE, XML_HEADER_GRID_LAYOUT,		XML_TOK_DATA_PILOT_TABLE_ATTR_HEADER_GRID_LAYOUT	},
 	XML_TOKEN_MAP_END
 };
 
diff -rup sc/source/filter/xml/xmlimprt.hxx sc/source/filter/xml/xmlimprt.hxx
--- sc/source/filter/xml/xmlimprt.hxx	2006-04-20 09:26:00.000000000 -0400
+++ sc/source/filter/xml/xmlimprt.hxx	2006-11-01 15:35:08.000000000 -0500
@@ -515,7 +515,8 @@ enum ScXMLDataPilotTableAttrTokens
 	XML_TOK_DATA_PILOT_TABLE_ATTR_TARGET_RANGE_ADDRESS,
 	XML_TOK_DATA_PILOT_TABLE_ATTR_BUTTONS,
     XML_TOK_DATA_PILOT_TABLE_ATTR_SHOW_FILTER_BUTTON,
-    XML_TOK_DATA_PILOT_TABLE_ATTR_DRILL_DOWN
+    XML_TOK_DATA_PILOT_TABLE_ATTR_DRILL_DOWN,
+    XML_TOK_DATA_PILOT_TABLE_ATTR_HEADER_GRID_LAYOUT
 };
 
 enum ScXMLDataPilotTableElemTokens
diff -rup xmloff/inc/xmltoken.hxx xmloff/inc/xmltoken.hxx
--- xmloff/inc/xmltoken.hxx	2005-11-14 04:12:45.000000000 -0500
+++ xmloff/inc/xmltoken.hxx	2006-11-01 15:33:48.000000000 -0500
@@ -2494,6 +2494,7 @@ namespace xmloff { namespace token {
 
         XML_SHOW_FILTER_BUTTON,
         XML_DRILL_DOWN_ON_DOUBLE_CLICK,
+        XML_HEADER_GRID_LAYOUT,
         XML_GROUPED_BY,
         XML_DAYS,
         XML_MONTHS,
diff -rup xmloff/source/core/xmltoken.cxx xmloff/source/core/xmltoken.cxx
--- xmloff/source/core/xmltoken.cxx	2006-10-24 09:33:59.000000000 -0400
+++ xmloff/source/core/xmltoken.cxx	2006-11-01 15:33:35.000000000 -0500
@@ -2499,6 +2499,7 @@ namespace xmloff { namespace token {
 
         TOKEN( "show-filter-button",                   XML_SHOW_FILTER_BUTTON ),
         TOKEN( "drill-down-on-double-click",           XML_DRILL_DOWN_ON_DOUBLE_CLICK ),
+        TOKEN( "header-grid-layout",           		   XML_HEADER_GRID_LAYOUT ),
         TOKEN( "grouped-by",                           XML_GROUPED_BY ),
         TOKEN( "days",                                 XML_DAYS ),
         TOKEN( "months",                               XML_MONTHS ),