Line data Source code
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 : #include "dpgroup.hxx"
21 : #include "dpsave.hxx"
22 : #include "xestream.hxx"
23 : #include "xistream.hxx"
24 : #include "xestring.hxx"
25 : #include "xlpivot.hxx"
26 : #include <osl/diagnose.h>
27 : #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
28 :
29 : using ::com::sun::star::sheet::GeneralFunction;
30 : using ::com::sun::star::sheet::DataPilotFieldOrientation;
31 :
32 : namespace ScDPSortMode = ::com::sun::star::sheet::DataPilotFieldSortMode;
33 : namespace ScDPShowItemsMode = ::com::sun::star::sheet::DataPilotFieldShowItemsMode;
34 : namespace ScDPLayoutMode = ::com::sun::star::sheet::DataPilotFieldLayoutMode;
35 : namespace ScDPRefItemType = ::com::sun::star::sheet::DataPilotFieldReferenceItemType;
36 : namespace ScDPGroupBy = ::com::sun::star::sheet::DataPilotFieldGroupBy;
37 :
38 : // Pivot cache
39 :
40 15 : XclPCItem::XclPCItem() :
41 : meType( EXC_PCITEM_INVALID ),
42 15 : maDateTime( DateTime::EMPTY )
43 : {
44 15 : }
45 :
46 15 : XclPCItem::~XclPCItem()
47 : {
48 15 : }
49 :
50 0 : void XclPCItem::SetEmpty()
51 : {
52 0 : meType = EXC_PCITEM_EMPTY;
53 0 : maText.clear();
54 0 : }
55 :
56 11 : void XclPCItem::SetText( const OUString& rText )
57 : {
58 11 : meType = EXC_PCITEM_TEXT;
59 11 : maText = rText;
60 11 : }
61 :
62 4 : void XclPCItem::SetDouble( double fValue )
63 : {
64 4 : meType = EXC_PCITEM_DOUBLE;
65 : //TODO convert double to string
66 4 : maText.clear();
67 4 : mfValue = fValue;
68 4 : }
69 :
70 0 : void XclPCItem::SetDateTime( const DateTime& rDateTime )
71 : {
72 0 : meType = EXC_PCITEM_DATETIME;
73 : //TODO convert date to string
74 0 : maText.clear();
75 0 : maDateTime = rDateTime;
76 0 : }
77 :
78 0 : void XclPCItem::SetInteger( sal_Int16 nValue )
79 : {
80 0 : meType = EXC_PCITEM_INTEGER;
81 0 : maText = OUString::number(nValue);
82 0 : mnValue = nValue;
83 0 : }
84 :
85 0 : void XclPCItem::SetError( sal_uInt16 nError )
86 : {
87 0 : meType = EXC_PCITEM_ERROR;
88 0 : maText.clear();
89 0 : mnError = nError;
90 0 : switch( nError )
91 : {
92 0 : case 0x00: maText = "#NULL!"; break;
93 0 : case 0x07: maText = "#DIV/0!"; break;
94 0 : case 0x0F: maText = "#VALUE!"; break;
95 0 : case 0x17: maText = "#REF!"; break;
96 0 : case 0x1D: maText = "#NAME?"; break;
97 0 : case 0x24: maText = "#NUM!"; break;
98 0 : case 0x2A: maText = "#N/A"; break;
99 0 : default: break;
100 : }
101 0 : }
102 :
103 0 : void XclPCItem::SetBool( bool bValue )
104 : {
105 0 : meType = EXC_PCITEM_BOOL;
106 : //TODO convert boolean to string
107 0 : maText.clear();
108 0 : mbValue = bValue;
109 0 : }
110 :
111 0 : bool XclPCItem::IsEqual( const XclPCItem& rItem ) const
112 : {
113 0 : if( meType == rItem.meType ) switch( meType )
114 : {
115 0 : case EXC_PCITEM_INVALID: return true;
116 0 : case EXC_PCITEM_EMPTY: return true;
117 0 : case EXC_PCITEM_TEXT: return maText == rItem.maText;
118 0 : case EXC_PCITEM_DOUBLE: return mfValue == rItem.mfValue;
119 0 : case EXC_PCITEM_DATETIME: return maDateTime == rItem.maDateTime;
120 0 : case EXC_PCITEM_INTEGER: return mnValue == rItem.mnValue;
121 0 : case EXC_PCITEM_BOOL: return mbValue == rItem.mbValue;
122 0 : case EXC_PCITEM_ERROR: return mnError == rItem.mnError;
123 : default: OSL_FAIL( "XclPCItem::IsEqual - unknown pivot cache item type" );
124 : }
125 0 : return false;
126 : }
127 :
128 8 : bool XclPCItem::IsEmpty() const
129 : {
130 8 : return meType == EXC_PCITEM_EMPTY;
131 : }
132 :
133 8 : const OUString* XclPCItem::GetText() const
134 : {
135 8 : return (meType == EXC_PCITEM_TEXT || meType == EXC_PCITEM_ERROR) ? &maText : NULL;
136 : }
137 :
138 0 : const double* XclPCItem::GetDouble() const
139 : {
140 0 : return (meType == EXC_PCITEM_DOUBLE) ? &mfValue : 0;
141 : }
142 :
143 0 : const DateTime* XclPCItem::GetDateTime() const
144 : {
145 0 : return (meType == EXC_PCITEM_DATETIME) ? &maDateTime : 0;
146 : }
147 :
148 0 : const sal_Int16* XclPCItem::GetInteger() const
149 : {
150 0 : return (meType == EXC_PCITEM_INTEGER) ? &mnValue : 0;
151 : }
152 :
153 0 : const sal_uInt16* XclPCItem::GetError() const
154 : {
155 0 : return (meType == EXC_PCITEM_ERROR) ? &mnError : 0;
156 : }
157 :
158 0 : const bool* XclPCItem::GetBool() const
159 : {
160 0 : return (meType == EXC_PCITEM_BOOL) ? &mbValue : 0;
161 : }
162 :
163 : // Field settings =============================================================
164 :
165 5 : XclPCFieldInfo::XclPCFieldInfo() :
166 : mnFlags( 0 ),
167 : mnGroupChild( 0 ),
168 : mnGroupBase( 0 ),
169 : mnVisItems( 0 ),
170 : mnGroupItems( 0 ),
171 : mnBaseItems( 0 ),
172 5 : mnOrigItems( 0 )
173 : {
174 5 : }
175 :
176 5 : XclImpStream& operator>>( XclImpStream& rStrm, XclPCFieldInfo& rInfo )
177 : {
178 5 : rInfo.mnFlags = rStrm.ReaduInt16();
179 5 : rInfo.mnGroupChild = rStrm.ReaduInt16();
180 5 : rInfo.mnGroupBase = rStrm.ReaduInt16();
181 5 : rInfo.mnVisItems = rStrm.ReaduInt16();
182 5 : rInfo.mnGroupItems = rStrm.ReaduInt16();
183 5 : rInfo.mnBaseItems = rStrm.ReaduInt16();
184 5 : rInfo.mnOrigItems = rStrm.ReaduInt16();
185 5 : if( rStrm.GetRecLeft() >= 3 )
186 5 : rInfo.maName = rStrm.ReadUniString();
187 : else
188 0 : rInfo.maName.clear();
189 5 : return rStrm;
190 : }
191 :
192 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPCFieldInfo& rInfo )
193 : {
194 : return rStrm
195 0 : << rInfo.mnFlags
196 0 : << rInfo.mnGroupChild
197 0 : << rInfo.mnGroupBase
198 0 : << rInfo.mnVisItems
199 0 : << rInfo.mnGroupItems
200 0 : << rInfo.mnBaseItems
201 0 : << rInfo.mnOrigItems
202 0 : << XclExpString( rInfo.maName );
203 : }
204 :
205 : // Numeric grouping field settings ============================================
206 :
207 5 : XclPCNumGroupInfo::XclPCNumGroupInfo() :
208 5 : mnFlags( EXC_SXNUMGROUP_AUTOMIN | EXC_SXNUMGROUP_AUTOMAX )
209 : {
210 5 : SetNumType();
211 5 : }
212 :
213 5 : void XclPCNumGroupInfo::SetNumType()
214 : {
215 5 : SetXclDataType( EXC_SXNUMGROUP_TYPE_NUM );
216 5 : }
217 :
218 0 : sal_Int32 XclPCNumGroupInfo::GetScDateType() const
219 : {
220 0 : sal_Int32 nScType = 0;
221 0 : switch( GetXclDataType() )
222 : {
223 0 : case EXC_SXNUMGROUP_TYPE_SEC: nScType = ScDPGroupBy::SECONDS; break;
224 0 : case EXC_SXNUMGROUP_TYPE_MIN: nScType = ScDPGroupBy::MINUTES; break;
225 0 : case EXC_SXNUMGROUP_TYPE_HOUR: nScType = ScDPGroupBy::HOURS; break;
226 0 : case EXC_SXNUMGROUP_TYPE_DAY: nScType = ScDPGroupBy::DAYS; break;
227 0 : case EXC_SXNUMGROUP_TYPE_MONTH: nScType = ScDPGroupBy::MONTHS; break;
228 0 : case EXC_SXNUMGROUP_TYPE_QUART: nScType = ScDPGroupBy::QUARTERS; break;
229 0 : case EXC_SXNUMGROUP_TYPE_YEAR: nScType = ScDPGroupBy::YEARS; break;
230 : default: OSL_TRACE( "XclPCNumGroupInfo::GetScDateType - unexpected date type %d", GetXclDataType() );
231 : }
232 0 : return nScType;
233 : }
234 :
235 0 : void XclPCNumGroupInfo::SetScDateType( sal_Int32 nScType )
236 : {
237 0 : sal_uInt16 nXclType = EXC_SXNUMGROUP_TYPE_NUM;
238 0 : switch( nScType )
239 : {
240 0 : case ScDPGroupBy::SECONDS: nXclType = EXC_SXNUMGROUP_TYPE_SEC; break;
241 0 : case ScDPGroupBy::MINUTES: nXclType = EXC_SXNUMGROUP_TYPE_MIN; break;
242 0 : case ScDPGroupBy::HOURS: nXclType = EXC_SXNUMGROUP_TYPE_HOUR; break;
243 0 : case ScDPGroupBy::DAYS: nXclType = EXC_SXNUMGROUP_TYPE_DAY; break;
244 0 : case ScDPGroupBy::MONTHS: nXclType = EXC_SXNUMGROUP_TYPE_MONTH; break;
245 0 : case ScDPGroupBy::QUARTERS: nXclType = EXC_SXNUMGROUP_TYPE_QUART; break;
246 0 : case ScDPGroupBy::YEARS: nXclType = EXC_SXNUMGROUP_TYPE_YEAR; break;
247 : default:
248 : SAL_INFO("sc.filter", "unexpected date type " << nScType);
249 : }
250 0 : SetXclDataType( nXclType );
251 0 : }
252 :
253 0 : sal_uInt16 XclPCNumGroupInfo::GetXclDataType() const
254 : {
255 0 : return ::extract_value< sal_uInt16 >( mnFlags, 2, 4 );
256 : }
257 :
258 5 : void XclPCNumGroupInfo::SetXclDataType( sal_uInt16 nXclType )
259 : {
260 5 : ::insert_value( mnFlags, nXclType, 2, 4 );
261 5 : }
262 :
263 0 : XclImpStream& operator>>( XclImpStream& rStrm, XclPCNumGroupInfo& rInfo )
264 : {
265 0 : rInfo.mnFlags = rStrm.ReaduInt16();
266 0 : return rStrm;;
267 : }
268 :
269 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPCNumGroupInfo& rInfo )
270 : {
271 0 : return rStrm << rInfo.mnFlags;
272 : }
273 :
274 : // Base class for pivot cache fields ==========================================
275 :
276 5 : XclPCField::XclPCField( XclPCFieldType eFieldType, sal_uInt16 nFieldIdx ) :
277 : meFieldType( eFieldType ),
278 5 : mnFieldIdx( nFieldIdx )
279 : {
280 5 : }
281 :
282 5 : XclPCField::~XclPCField()
283 : {
284 5 : }
285 :
286 7 : bool XclPCField::IsSupportedField() const
287 : {
288 7 : return (meFieldType != EXC_PCFIELD_CALCED) && (meFieldType != EXC_PCFIELD_UNKNOWN);
289 : }
290 :
291 40 : bool XclPCField::IsStandardField() const
292 : {
293 40 : return meFieldType == EXC_PCFIELD_STANDARD;
294 : }
295 :
296 2 : bool XclPCField::IsStdGroupField() const
297 : {
298 2 : return meFieldType == EXC_PCFIELD_STDGROUP;
299 : }
300 :
301 2 : bool XclPCField::IsNumGroupField() const
302 : {
303 2 : return meFieldType == EXC_PCFIELD_NUMGROUP;
304 : }
305 :
306 2 : bool XclPCField::IsDateGroupField() const
307 : {
308 2 : return (meFieldType == EXC_PCFIELD_DATEGROUP) || (meFieldType == EXC_PCFIELD_DATECHILD);
309 : }
310 :
311 0 : bool XclPCField::IsGroupField() const
312 : {
313 0 : return IsStdGroupField() || IsNumGroupField() || IsDateGroupField();
314 : }
315 :
316 0 : bool XclPCField::IsGroupBaseField() const
317 : {
318 0 : return ::get_flag( maFieldInfo.mnFlags, EXC_SXFIELD_HASCHILD );
319 : }
320 :
321 6 : bool XclPCField::IsGroupChildField() const
322 : {
323 6 : return (meFieldType == EXC_PCFIELD_STDGROUP) || (meFieldType == EXC_PCFIELD_DATECHILD);
324 : }
325 :
326 5 : bool XclPCField::HasOrigItems() const
327 : {
328 5 : return IsSupportedField() && ((maFieldInfo.mnOrigItems > 0) || HasPostponedItems());
329 : }
330 :
331 20 : bool XclPCField::HasInlineItems() const
332 : {
333 20 : return (IsStandardField() || IsGroupField()) && ((maFieldInfo.mnGroupItems > 0) || (maFieldInfo.mnOrigItems > 0));
334 : }
335 :
336 5 : bool XclPCField::HasPostponedItems() const
337 : {
338 5 : return IsStandardField() && ::get_flag( maFieldInfo.mnFlags, EXC_SXFIELD_POSTPONE );
339 : }
340 :
341 0 : bool XclPCField::Has16BitIndexes() const
342 : {
343 0 : return IsStandardField() && ::get_flag( maFieldInfo.mnFlags, EXC_SXFIELD_16BIT );
344 : }
345 :
346 : // Pivot cache settings =======================================================
347 :
348 : /** Contains data for a pivot cache (SXDB record). */
349 2 : XclPCInfo::XclPCInfo() :
350 : mnSrcRecs( 0 ),
351 : mnStrmId( 0xFFFF ),
352 : mnFlags( EXC_SXDB_DEFAULTFLAGS ),
353 : mnBlockRecs( EXC_SXDB_BLOCKRECS ),
354 : mnStdFields( 0 ),
355 : mnTotalFields( 0 ),
356 2 : mnSrcType( EXC_SXDB_SRC_SHEET )
357 : {
358 2 : }
359 :
360 2 : XclImpStream& operator>>( XclImpStream& rStrm, XclPCInfo& rInfo )
361 : {
362 2 : rInfo.mnSrcRecs = rStrm.ReaduInt32();
363 2 : rInfo.mnStrmId = rStrm.ReaduInt16();
364 2 : rInfo.mnFlags = rStrm.ReaduInt16();
365 2 : rInfo.mnBlockRecs = rStrm.ReaduInt16();
366 2 : rInfo.mnStdFields = rStrm.ReaduInt16();
367 2 : rInfo.mnTotalFields = rStrm.ReaduInt16();
368 2 : rStrm.Ignore( 2 );
369 2 : rInfo.mnSrcType = rStrm.ReaduInt16();
370 2 : rInfo.maUserName = rStrm.ReadUniString();
371 2 : return rStrm;
372 : }
373 :
374 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPCInfo& rInfo )
375 : {
376 : return rStrm
377 0 : << rInfo.mnSrcRecs
378 0 : << rInfo.mnStrmId
379 0 : << rInfo.mnFlags
380 0 : << rInfo.mnBlockRecs
381 0 : << rInfo.mnStdFields
382 0 : << rInfo.mnTotalFields
383 0 : << sal_uInt16( 0 )
384 0 : << rInfo.mnSrcType
385 0 : << XclExpString( rInfo.maUserName );
386 : }
387 :
388 : // Pivot table
389 :
390 : // cached name ================================================================
391 :
392 21 : XclImpStream& operator>>( XclImpStream& rStrm, XclPTCachedName& rCachedName )
393 : {
394 : sal_uInt16 nStrLen;
395 21 : nStrLen = rStrm.ReaduInt16();
396 21 : rCachedName.mbUseCache = nStrLen == EXC_PT_NOSTRING;
397 21 : if( rCachedName.mbUseCache )
398 20 : rCachedName.maName.clear();
399 : else
400 1 : rCachedName.maName = rStrm.ReadUniString( nStrLen );
401 21 : return rStrm;
402 : }
403 :
404 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPTCachedName& rCachedName )
405 : {
406 0 : if( rCachedName.mbUseCache )
407 0 : rStrm << EXC_PT_NOSTRING;
408 : else
409 0 : rStrm << XclExpString( rCachedName.maName, EXC_STR_DEFAULT, EXC_PT_MAXSTRLEN );
410 0 : return rStrm;
411 : }
412 :
413 8 : const OUString* XclPTVisNameInfo::GetVisName() const
414 : {
415 8 : return HasVisName() ? &maVisName.maName : 0;
416 : }
417 :
418 0 : void XclPTVisNameInfo::SetVisName( const OUString& rName )
419 : {
420 0 : maVisName.maName = rName;
421 0 : maVisName.mbUseCache = rName.isEmpty();
422 0 : }
423 :
424 : // Field item settings ========================================================
425 :
426 15 : XclPTItemInfo::XclPTItemInfo() :
427 : mnType( EXC_SXVI_TYPE_DATA ),
428 : mnFlags( EXC_SXVI_DEFAULTFLAGS ),
429 15 : mnCacheIdx( EXC_SXVI_DEFAULT_CACHE )
430 : {
431 15 : }
432 :
433 15 : XclImpStream& operator>>( XclImpStream& rStrm, XclPTItemInfo& rInfo )
434 : {
435 15 : rInfo.mnType = rStrm.ReaduInt16();
436 15 : rInfo.mnFlags = rStrm.ReaduInt16();
437 15 : rInfo.mnCacheIdx = rStrm.ReaduInt16();
438 15 : rStrm >> rInfo.maVisName;
439 15 : return rStrm;
440 : }
441 :
442 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPTItemInfo& rInfo )
443 : {
444 : return rStrm
445 0 : << rInfo.mnType
446 0 : << rInfo.mnFlags
447 0 : << rInfo.mnCacheIdx
448 0 : << rInfo.maVisName;
449 : }
450 :
451 : // General field settings =====================================================
452 :
453 7 : XclPTFieldInfo::XclPTFieldInfo() :
454 : mnAxes( EXC_SXVD_AXIS_NONE ),
455 : mnSubtCount( 1 ),
456 : mnSubtotals( EXC_SXVD_SUBT_DEFAULT ),
457 : mnItemCount( 0 ),
458 7 : mnCacheIdx( EXC_SXVD_DEFAULT_CACHE )
459 : {
460 7 : }
461 :
462 2 : DataPilotFieldOrientation XclPTFieldInfo::GetApiOrient( sal_uInt16 nMask ) const
463 : {
464 : using namespace ::com::sun::star::sheet;
465 2 : DataPilotFieldOrientation eOrient = DataPilotFieldOrientation_HIDDEN;
466 2 : sal_uInt16 nUsedAxes = mnAxes & nMask;
467 2 : if( nUsedAxes & EXC_SXVD_AXIS_ROW )
468 2 : eOrient = DataPilotFieldOrientation_ROW;
469 0 : else if( nUsedAxes & EXC_SXVD_AXIS_COL )
470 0 : eOrient = DataPilotFieldOrientation_COLUMN;
471 0 : else if( nUsedAxes & EXC_SXVD_AXIS_PAGE )
472 0 : eOrient = DataPilotFieldOrientation_PAGE;
473 0 : else if( nUsedAxes & EXC_SXVD_AXIS_DATA )
474 0 : eOrient = DataPilotFieldOrientation_DATA;
475 2 : return eOrient;
476 : }
477 :
478 0 : void XclPTFieldInfo::AddApiOrient( DataPilotFieldOrientation eOrient )
479 : {
480 : using namespace ::com::sun::star::sheet;
481 0 : switch( eOrient )
482 : {
483 0 : case DataPilotFieldOrientation_ROW: mnAxes |= EXC_SXVD_AXIS_ROW; break;
484 0 : case DataPilotFieldOrientation_COLUMN: mnAxes |= EXC_SXVD_AXIS_COL; break;
485 0 : case DataPilotFieldOrientation_PAGE: mnAxes |= EXC_SXVD_AXIS_PAGE; break;
486 0 : case DataPilotFieldOrientation_DATA: mnAxes |= EXC_SXVD_AXIS_DATA; break;
487 : default:;
488 : }
489 0 : }
490 :
491 : //TODO: should be a Sequence<GeneralFunction> in ScDPSaveData
492 2 : void XclPTFieldInfo::GetSubtotals( XclPTSubtotalVec& rSubtotals ) const
493 : {
494 2 : rSubtotals.clear();
495 2 : rSubtotals.reserve( 16 );
496 :
497 : using namespace ::com::sun::star::sheet;
498 2 : if( mnSubtotals & EXC_SXVD_SUBT_DEFAULT ) rSubtotals.push_back( GeneralFunction_AUTO );
499 2 : if( mnSubtotals & EXC_SXVD_SUBT_SUM ) rSubtotals.push_back( GeneralFunction_SUM );
500 2 : if( mnSubtotals & EXC_SXVD_SUBT_COUNT ) rSubtotals.push_back( GeneralFunction_COUNT );
501 2 : if( mnSubtotals & EXC_SXVD_SUBT_AVERAGE ) rSubtotals.push_back( GeneralFunction_AVERAGE );
502 2 : if( mnSubtotals & EXC_SXVD_SUBT_MAX ) rSubtotals.push_back( GeneralFunction_MAX );
503 2 : if( mnSubtotals & EXC_SXVD_SUBT_MIN ) rSubtotals.push_back( GeneralFunction_MIN );
504 2 : if( mnSubtotals & EXC_SXVD_SUBT_PROD ) rSubtotals.push_back( GeneralFunction_PRODUCT );
505 2 : if( mnSubtotals & EXC_SXVD_SUBT_COUNTNUM ) rSubtotals.push_back( GeneralFunction_COUNTNUMS );
506 2 : if( mnSubtotals & EXC_SXVD_SUBT_STDDEV ) rSubtotals.push_back( GeneralFunction_STDEV );
507 2 : if( mnSubtotals & EXC_SXVD_SUBT_STDDEVP ) rSubtotals.push_back( GeneralFunction_STDEVP );
508 2 : if( mnSubtotals & EXC_SXVD_SUBT_VAR ) rSubtotals.push_back( GeneralFunction_VAR );
509 2 : if( mnSubtotals & EXC_SXVD_SUBT_VARP ) rSubtotals.push_back( GeneralFunction_VARP );
510 2 : }
511 :
512 0 : void XclPTFieldInfo::SetSubtotals( const XclPTSubtotalVec& rSubtotals )
513 : {
514 0 : mnSubtotals = EXC_SXVD_SUBT_NONE;
515 : using namespace ::com::sun::star::sheet;
516 0 : for( XclPTSubtotalVec::const_iterator aIt = rSubtotals.begin(), aEnd = rSubtotals.end(); aIt != aEnd; ++aIt )
517 : {
518 0 : switch( *aIt )
519 : {
520 0 : case GeneralFunction_AUTO: mnSubtotals |= EXC_SXVD_SUBT_DEFAULT; break;
521 0 : case GeneralFunction_SUM: mnSubtotals |= EXC_SXVD_SUBT_SUM; break;
522 0 : case GeneralFunction_COUNT: mnSubtotals |= EXC_SXVD_SUBT_COUNT; break;
523 0 : case GeneralFunction_AVERAGE: mnSubtotals |= EXC_SXVD_SUBT_AVERAGE; break;
524 0 : case GeneralFunction_MAX: mnSubtotals |= EXC_SXVD_SUBT_MAX; break;
525 0 : case GeneralFunction_MIN: mnSubtotals |= EXC_SXVD_SUBT_MIN; break;
526 0 : case GeneralFunction_PRODUCT: mnSubtotals |= EXC_SXVD_SUBT_PROD; break;
527 0 : case GeneralFunction_COUNTNUMS: mnSubtotals |= EXC_SXVD_SUBT_COUNTNUM; break;
528 0 : case GeneralFunction_STDEV: mnSubtotals |= EXC_SXVD_SUBT_STDDEV; break;
529 0 : case GeneralFunction_STDEVP: mnSubtotals |= EXC_SXVD_SUBT_STDDEVP; break;
530 0 : case GeneralFunction_VAR: mnSubtotals |= EXC_SXVD_SUBT_VAR; break;
531 0 : case GeneralFunction_VARP: mnSubtotals |= EXC_SXVD_SUBT_VARP; break;
532 : }
533 : }
534 :
535 0 : mnSubtCount = 0;
536 0 : for( sal_uInt16 nMask = 0x8000; nMask; nMask >>= 1 )
537 0 : if( mnSubtotals & nMask )
538 0 : ++mnSubtCount;
539 0 : }
540 :
541 5 : XclImpStream& operator>>( XclImpStream& rStrm, XclPTFieldInfo& rInfo )
542 : {
543 : // rInfo.mnCacheIdx is not part of the SXVD record
544 5 : rInfo.mnAxes = rStrm.ReaduInt16();
545 5 : rInfo.mnSubtCount = rStrm.ReaduInt16();
546 5 : rInfo.mnSubtotals = rStrm.ReaduInt16();
547 5 : rInfo.mnItemCount = rStrm.ReaduInt16();
548 5 : rStrm >> rInfo.maVisName;
549 5 : return rStrm;
550 : }
551 :
552 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldInfo& rInfo )
553 : {
554 : // rInfo.mnCacheIdx is not part of the SXVD record
555 : return rStrm
556 0 : << rInfo.mnAxes
557 0 : << rInfo.mnSubtCount
558 0 : << rInfo.mnSubtotals
559 0 : << rInfo.mnItemCount
560 0 : << rInfo.maVisName;
561 : }
562 :
563 : // Extended field settings ====================================================
564 :
565 7 : XclPTFieldExtInfo::XclPTFieldExtInfo() :
566 : mnFlags( EXC_SXVDEX_DEFAULTFLAGS ),
567 : mnSortField( EXC_SXVDEX_SORT_OWN ),
568 : mnShowField( EXC_SXVDEX_SHOW_NONE ),
569 : mnNumFmt(0),
570 7 : mpFieldTotalName(NULL)
571 : {
572 7 : }
573 :
574 2 : sal_Int32 XclPTFieldExtInfo::GetApiSortMode() const
575 : {
576 2 : sal_Int32 nSortMode = ScDPSortMode::MANUAL;
577 2 : if( ::get_flag( mnFlags, EXC_SXVDEX_SORT ) )
578 0 : nSortMode = (mnSortField == EXC_SXVDEX_SORT_OWN) ? ScDPSortMode::NAME : ScDPSortMode::DATA;
579 2 : return nSortMode;
580 : }
581 :
582 0 : void XclPTFieldExtInfo::SetApiSortMode( sal_Int32 nSortMode )
583 : {
584 0 : bool bSort = (nSortMode == ScDPSortMode::NAME) || (nSortMode == ScDPSortMode::DATA);
585 0 : ::set_flag( mnFlags, EXC_SXVDEX_SORT, bSort );
586 0 : if( nSortMode == ScDPSortMode::NAME )
587 0 : mnSortField = EXC_SXVDEX_SORT_OWN; // otherwise sort field has to be set by caller
588 0 : }
589 :
590 2 : sal_Int32 XclPTFieldExtInfo::GetApiAutoShowMode() const
591 : {
592 : return ::get_flagvalue( mnFlags, EXC_SXVDEX_AUTOSHOW_ASC,
593 2 : ScDPShowItemsMode::FROM_TOP, ScDPShowItemsMode::FROM_BOTTOM );
594 : }
595 :
596 0 : void XclPTFieldExtInfo::SetApiAutoShowMode( sal_Int32 nShowMode )
597 : {
598 0 : ::set_flag( mnFlags, EXC_SXVDEX_AUTOSHOW_ASC, nShowMode == ScDPShowItemsMode::FROM_TOP );
599 0 : }
600 :
601 2 : sal_Int32 XclPTFieldExtInfo::GetApiAutoShowCount() const
602 : {
603 2 : return ::extract_value< sal_Int32 >( mnFlags, 24, 8 );
604 : }
605 :
606 0 : void XclPTFieldExtInfo::SetApiAutoShowCount( sal_Int32 nShowCount )
607 : {
608 0 : ::insert_value( mnFlags, limit_cast< sal_uInt8 >( nShowCount ), 24, 8 );
609 0 : }
610 :
611 2 : sal_Int32 XclPTFieldExtInfo::GetApiLayoutMode() const
612 : {
613 2 : sal_Int32 nLayoutMode = ScDPLayoutMode::TABULAR_LAYOUT;
614 2 : if( ::get_flag( mnFlags, EXC_SXVDEX_LAYOUT_REPORT ) )
615 0 : nLayoutMode = ::get_flag( mnFlags, EXC_SXVDEX_LAYOUT_TOP ) ?
616 0 : ScDPLayoutMode::OUTLINE_SUBTOTALS_TOP : ScDPLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
617 2 : return nLayoutMode;
618 : }
619 :
620 0 : void XclPTFieldExtInfo::SetApiLayoutMode( sal_Int32 nLayoutMode )
621 : {
622 0 : ::set_flag( mnFlags, EXC_SXVDEX_LAYOUT_REPORT, nLayoutMode != ScDPLayoutMode::TABULAR_LAYOUT );
623 0 : ::set_flag( mnFlags, EXC_SXVDEX_LAYOUT_TOP, nLayoutMode == ScDPLayoutMode::OUTLINE_SUBTOTALS_TOP );
624 0 : }
625 :
626 5 : XclImpStream& operator>>( XclImpStream& rStrm, XclPTFieldExtInfo& rInfo )
627 : {
628 5 : sal_uInt8 nNameLen = 0;
629 5 : rInfo.mnFlags = rStrm.ReaduInt32();
630 5 : rInfo.mnSortField = rStrm.ReaduInt16();
631 5 : rInfo.mnShowField = rStrm.ReaduInt16();
632 5 : rInfo.mnNumFmt = rStrm.ReaduInt16();
633 5 : nNameLen = rStrm.ReaduInt8();
634 :
635 5 : rStrm.Ignore(10);
636 5 : if (nNameLen != 0xFF)
637 : // Custom field total name is used. Pick it up.
638 0 : rInfo.mpFieldTotalName.reset(new OUString(rStrm.ReadUniString(nNameLen, 0)));
639 :
640 5 : return rStrm;
641 : }
642 :
643 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldExtInfo& rInfo )
644 : {
645 0 : rStrm << rInfo.mnFlags
646 0 : << rInfo.mnSortField
647 0 : << rInfo.mnShowField
648 0 : << EXC_SXVDEX_FORMAT_NONE;
649 :
650 0 : if (rInfo.mpFieldTotalName.get() && !rInfo.mpFieldTotalName->isEmpty())
651 : {
652 0 : OUString aFinalName = *rInfo.mpFieldTotalName;
653 0 : if (aFinalName.getLength() >= 254)
654 0 : aFinalName = aFinalName.copy(0, 254);
655 0 : sal_uInt8 nNameLen = static_cast<sal_uInt8>(aFinalName.getLength());
656 0 : rStrm << nNameLen;
657 0 : rStrm.WriteZeroBytes(10);
658 0 : rStrm << XclExpString(aFinalName, EXC_STR_NOHEADER);
659 : }
660 : else
661 : {
662 0 : rStrm << sal_uInt16(0xFFFF);
663 0 : rStrm.WriteZeroBytes(8);
664 : }
665 0 : return rStrm;
666 : }
667 :
668 : // Page field settings ========================================================
669 :
670 7 : XclPTPageFieldInfo::XclPTPageFieldInfo() :
671 : mnField( 0 ),
672 : mnSelItem( EXC_SXPI_ALLITEMS ),
673 7 : mnObjId( 0xFFFF )
674 : {
675 7 : }
676 :
677 0 : XclImpStream& operator>>( XclImpStream& rStrm, XclPTPageFieldInfo& rInfo )
678 : {
679 0 : rInfo.mnField = rStrm.ReaduInt16();
680 0 : rInfo.mnSelItem = rStrm.ReaduInt16();
681 0 : rInfo.mnObjId = rStrm.ReaduInt16();
682 0 : return rStrm;
683 : }
684 :
685 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPTPageFieldInfo& rInfo )
686 : {
687 : return rStrm
688 0 : << rInfo.mnField
689 0 : << rInfo.mnSelItem
690 0 : << rInfo.mnObjId;
691 : }
692 :
693 : // Data field settings ========================================================
694 :
695 1 : XclPTDataFieldInfo::XclPTDataFieldInfo() :
696 : mnField( 0 ),
697 : mnAggFunc( EXC_SXDI_FUNC_SUM ),
698 : mnRefType( EXC_SXDI_REF_NORMAL ),
699 : mnRefField( 0 ),
700 : mnRefItem( 0 ),
701 1 : mnNumFmt( 0 )
702 : {
703 1 : }
704 :
705 1 : GeneralFunction XclPTDataFieldInfo::GetApiAggFunc() const
706 : {
707 : using namespace ::com::sun::star::sheet;
708 : GeneralFunction eAggFunc;
709 1 : switch( mnAggFunc )
710 : {
711 1 : case EXC_SXDI_FUNC_SUM: eAggFunc = GeneralFunction_SUM; break;
712 0 : case EXC_SXDI_FUNC_COUNT: eAggFunc = GeneralFunction_COUNT; break;
713 0 : case EXC_SXDI_FUNC_AVERAGE: eAggFunc = GeneralFunction_AVERAGE; break;
714 0 : case EXC_SXDI_FUNC_MAX: eAggFunc = GeneralFunction_MAX; break;
715 0 : case EXC_SXDI_FUNC_MIN: eAggFunc = GeneralFunction_MIN; break;
716 0 : case EXC_SXDI_FUNC_PRODUCT: eAggFunc = GeneralFunction_PRODUCT; break;
717 0 : case EXC_SXDI_FUNC_COUNTNUM: eAggFunc = GeneralFunction_COUNTNUMS; break;
718 0 : case EXC_SXDI_FUNC_STDDEV: eAggFunc = GeneralFunction_STDEV; break;
719 0 : case EXC_SXDI_FUNC_STDDEVP: eAggFunc = GeneralFunction_STDEVP; break;
720 0 : case EXC_SXDI_FUNC_VAR: eAggFunc = GeneralFunction_VAR; break;
721 0 : case EXC_SXDI_FUNC_VARP: eAggFunc = GeneralFunction_VARP; break;
722 0 : default: eAggFunc = GeneralFunction_SUM;
723 : }
724 1 : return eAggFunc;
725 : }
726 :
727 0 : void XclPTDataFieldInfo::SetApiAggFunc( GeneralFunction eAggFunc )
728 : {
729 : using namespace ::com::sun::star::sheet;
730 0 : switch( eAggFunc )
731 : {
732 0 : case GeneralFunction_SUM: mnAggFunc = EXC_SXDI_FUNC_SUM; break;
733 0 : case GeneralFunction_COUNT: mnAggFunc = EXC_SXDI_FUNC_COUNT; break;
734 0 : case GeneralFunction_AVERAGE: mnAggFunc = EXC_SXDI_FUNC_AVERAGE; break;
735 0 : case GeneralFunction_MAX: mnAggFunc = EXC_SXDI_FUNC_MAX; break;
736 0 : case GeneralFunction_MIN: mnAggFunc = EXC_SXDI_FUNC_MIN; break;
737 0 : case GeneralFunction_PRODUCT: mnAggFunc = EXC_SXDI_FUNC_PRODUCT; break;
738 0 : case GeneralFunction_COUNTNUMS: mnAggFunc = EXC_SXDI_FUNC_COUNTNUM; break;
739 0 : case GeneralFunction_STDEV: mnAggFunc = EXC_SXDI_FUNC_STDDEV; break;
740 0 : case GeneralFunction_STDEVP: mnAggFunc = EXC_SXDI_FUNC_STDDEVP; break;
741 0 : case GeneralFunction_VAR: mnAggFunc = EXC_SXDI_FUNC_VAR; break;
742 0 : case GeneralFunction_VARP: mnAggFunc = EXC_SXDI_FUNC_VARP; break;
743 0 : default: mnAggFunc = EXC_SXDI_FUNC_SUM;
744 : }
745 0 : }
746 :
747 1 : sal_Int32 XclPTDataFieldInfo::GetApiRefType() const
748 : {
749 : namespace ScDPRefType = ::com::sun::star::sheet::DataPilotFieldReferenceType;
750 : sal_Int32 nRefType;
751 1 : switch( mnRefType )
752 : {
753 0 : case EXC_SXDI_REF_DIFF: nRefType = ScDPRefType::ITEM_DIFFERENCE; break;
754 0 : case EXC_SXDI_REF_PERC: nRefType = ScDPRefType::ITEM_PERCENTAGE; break;
755 0 : case EXC_SXDI_REF_PERC_DIFF: nRefType = ScDPRefType::ITEM_PERCENTAGE_DIFFERENCE; break;
756 0 : case EXC_SXDI_REF_RUN_TOTAL: nRefType = ScDPRefType::RUNNING_TOTAL; break;
757 0 : case EXC_SXDI_REF_PERC_ROW: nRefType = ScDPRefType::ROW_PERCENTAGE; break;
758 0 : case EXC_SXDI_REF_PERC_COL: nRefType = ScDPRefType::COLUMN_PERCENTAGE; break;
759 0 : case EXC_SXDI_REF_PERC_TOTAL: nRefType = ScDPRefType::TOTAL_PERCENTAGE; break;
760 0 : case EXC_SXDI_REF_INDEX: nRefType = ScDPRefType::INDEX; break;
761 1 : default: nRefType = ScDPRefType::NONE;
762 : }
763 1 : return nRefType;
764 : }
765 :
766 0 : void XclPTDataFieldInfo::SetApiRefType( sal_Int32 nRefType )
767 : {
768 : namespace ScDPRefType = ::com::sun::star::sheet::DataPilotFieldReferenceType;
769 0 : switch( nRefType )
770 : {
771 0 : case ScDPRefType::ITEM_DIFFERENCE: mnRefType = EXC_SXDI_REF_DIFF; break;
772 0 : case ScDPRefType::ITEM_PERCENTAGE: mnRefType = EXC_SXDI_REF_PERC; break;
773 0 : case ScDPRefType::ITEM_PERCENTAGE_DIFFERENCE: mnRefType = EXC_SXDI_REF_PERC_DIFF; break;
774 0 : case ScDPRefType::RUNNING_TOTAL: mnRefType = EXC_SXDI_REF_RUN_TOTAL; break;
775 0 : case ScDPRefType::ROW_PERCENTAGE: mnRefType = EXC_SXDI_REF_PERC_ROW; break;
776 0 : case ScDPRefType::COLUMN_PERCENTAGE: mnRefType = EXC_SXDI_REF_PERC_COL; break;
777 0 : case ScDPRefType::TOTAL_PERCENTAGE: mnRefType = EXC_SXDI_REF_PERC_TOTAL;break;
778 0 : case ScDPRefType::INDEX: mnRefType = EXC_SXDI_REF_INDEX; break;
779 0 : default: mnRefType = EXC_SXDI_REF_NORMAL;
780 : }
781 0 : }
782 :
783 1 : sal_Int32 XclPTDataFieldInfo::GetApiRefItemType() const
784 : {
785 : sal_Int32 nRefItemType;
786 1 : switch( mnRefItem )
787 : {
788 0 : case EXC_SXDI_PREVITEM: nRefItemType = ScDPRefItemType::PREVIOUS; break;
789 0 : case EXC_SXDI_NEXTITEM: nRefItemType = ScDPRefItemType::NEXT; break;
790 1 : default: nRefItemType = ScDPRefItemType::NAMED;
791 : }
792 1 : return nRefItemType;
793 : }
794 :
795 0 : void XclPTDataFieldInfo::SetApiRefItemType( sal_Int32 nRefItemType )
796 : {
797 0 : switch( nRefItemType )
798 : {
799 0 : case ScDPRefItemType::PREVIOUS: mnRefItem = EXC_SXDI_PREVITEM; break;
800 0 : case ScDPRefItemType::NEXT: mnRefItem = EXC_SXDI_NEXTITEM; break;
801 : // nothing for named item reference
802 : }
803 0 : }
804 :
805 1 : XclImpStream& operator>>( XclImpStream& rStrm, XclPTDataFieldInfo& rInfo )
806 : {
807 1 : rInfo.mnField = rStrm.ReaduInt16();
808 1 : rInfo.mnAggFunc = rStrm.ReaduInt16();
809 1 : rInfo.mnRefType = rStrm.ReaduInt16();
810 1 : rInfo.mnRefField = rStrm.ReaduInt16();
811 1 : rInfo.mnRefItem = rStrm.ReaduInt16();
812 1 : rInfo.mnNumFmt = rStrm.ReaduInt16();
813 1 : rStrm >> rInfo.maVisName;
814 1 : return rStrm;
815 : }
816 :
817 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPTDataFieldInfo& rInfo )
818 : {
819 : return rStrm
820 0 : << rInfo.mnField
821 0 : << rInfo.mnAggFunc
822 0 : << rInfo.mnRefType
823 0 : << rInfo.mnRefField
824 0 : << rInfo.mnRefItem
825 0 : << rInfo.mnNumFmt
826 0 : << rInfo.maVisName;
827 : }
828 :
829 : // Pivot table settings =======================================================
830 :
831 2 : XclPTInfo::XclPTInfo() :
832 : mnFirstHeadRow( 0 ),
833 : mnCacheIdx( 0xFFFF ),
834 : mnDataAxis( EXC_SXVD_AXIS_NONE ),
835 : mnDataPos( EXC_SXVIEW_DATALAST ),
836 : mnFields( 0 ),
837 : mnRowFields( 0 ),
838 : mnColFields( 0 ),
839 : mnPageFields( 0 ),
840 : mnDataFields( 0 ),
841 : mnDataRows( 0 ),
842 : mnDataCols( 0 ),
843 : mnFlags( EXC_SXVIEW_DEFAULTFLAGS ),
844 2 : mnAutoFmtIdx( EXC_SXVIEW_AUTOFMT )
845 : {
846 2 : }
847 :
848 2 : XclImpStream& operator>>( XclImpStream& rStrm, XclPTInfo& rInfo )
849 : {
850 : sal_uInt16 nTabLen, nDataLen;
851 :
852 2 : rStrm >> rInfo.maOutXclRange;
853 2 : rInfo.mnFirstHeadRow = rStrm.ReaduInt16();
854 2 : rStrm >> rInfo.maDataXclPos;
855 2 : rInfo.mnCacheIdx = rStrm.ReaduInt16();
856 2 : rStrm.Ignore( 2 );
857 2 : rInfo.mnDataAxis = rStrm.ReaduInt16();
858 2 : rInfo.mnDataPos = rStrm.ReaduInt16();
859 2 : rInfo.mnFields = rStrm.ReaduInt16();
860 2 : rInfo.mnRowFields = rStrm.ReaduInt16();
861 2 : rInfo.mnColFields = rStrm.ReaduInt16();
862 2 : rInfo.mnPageFields = rStrm.ReaduInt16();
863 2 : rInfo.mnDataFields = rStrm.ReaduInt16();
864 2 : rInfo.mnDataRows = rStrm.ReaduInt16();
865 2 : rInfo.mnDataCols = rStrm.ReaduInt16();
866 2 : rInfo.mnFlags = rStrm.ReaduInt16();
867 2 : rInfo.mnAutoFmtIdx = rStrm.ReaduInt16();
868 2 : nTabLen = rStrm.ReaduInt16();
869 2 : nDataLen = rStrm.ReaduInt16();
870 2 : rInfo.maTableName = rStrm.ReadUniString( nTabLen );
871 2 : rInfo.maDataName = rStrm.ReadUniString( nDataLen );
872 2 : return rStrm;
873 : }
874 :
875 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPTInfo& rInfo )
876 : {
877 0 : XclExpString aXclTableName( rInfo.maTableName );
878 0 : XclExpString aXclDataName( rInfo.maDataName );
879 :
880 0 : rStrm << rInfo.maOutXclRange
881 0 : << rInfo.mnFirstHeadRow
882 0 : << rInfo.maDataXclPos
883 0 : << rInfo.mnCacheIdx
884 0 : << sal_uInt16( 0 )
885 0 : << rInfo.mnDataAxis << rInfo.mnDataPos
886 0 : << rInfo.mnFields
887 0 : << rInfo.mnRowFields << rInfo.mnColFields
888 0 : << rInfo.mnPageFields << rInfo.mnDataFields
889 0 : << rInfo.mnDataRows << rInfo.mnDataCols
890 0 : << rInfo.mnFlags
891 0 : << rInfo.mnAutoFmtIdx
892 0 : << aXclTableName.Len() << aXclDataName.Len();
893 0 : aXclTableName.WriteFlagField( rStrm );
894 0 : aXclTableName.WriteBuffer( rStrm );
895 0 : aXclDataName.WriteFlagField( rStrm );
896 0 : aXclDataName.WriteBuffer( rStrm );
897 0 : return rStrm;
898 : }
899 :
900 : // Extended pivot table settings ==============================================
901 :
902 2 : XclPTExtInfo::XclPTExtInfo() :
903 : mnSxformulaRecs( 0 ),
904 : mnSxselectRecs( 0 ),
905 : mnPagePerRow( 0 ),
906 : mnPagePerCol( 0 ),
907 2 : mnFlags( EXC_SXEX_DEFAULTFLAGS )
908 : {
909 2 : }
910 :
911 2 : XclImpStream& operator>>( XclImpStream& rStrm, XclPTExtInfo& rInfo )
912 : {
913 2 : rInfo.mnSxformulaRecs = rStrm.ReaduInt16();
914 2 : rStrm.Ignore( 6 );
915 2 : rInfo.mnSxselectRecs = rStrm.ReaduInt16();
916 2 : rInfo.mnPagePerRow = rStrm.ReaduInt16();
917 2 : rInfo.mnPagePerCol = rStrm.ReaduInt16();
918 2 : rInfo.mnFlags = rStrm.ReaduInt32();
919 2 : return rStrm;
920 : }
921 :
922 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPTExtInfo& rInfo )
923 : {
924 : return rStrm
925 0 : << rInfo.mnSxformulaRecs
926 0 : << EXC_PT_NOSTRING // length of alt. error text
927 0 : << EXC_PT_NOSTRING // length of alt. empty text
928 0 : << EXC_PT_NOSTRING // length of tag
929 0 : << rInfo.mnSxselectRecs
930 0 : << rInfo.mnPagePerRow
931 0 : << rInfo.mnPagePerCol
932 0 : << rInfo.mnFlags
933 0 : << EXC_PT_NOSTRING // length of page field style name
934 0 : << EXC_PT_NOSTRING // length of table style name
935 0 : << EXC_PT_NOSTRING; // length of vacate style name
936 : }
937 :
938 : // Pivot table autoformat settings ============================================
939 :
940 : /**
941 : classic : 10 08 00 00 00 00 00 00 20 00 00 00 01 00 00 00 00
942 : default : 10 08 00 00 00 00 00 00 20 00 00 00 01 00 00 00 00
943 : report01 : 10 08 02 00 00 00 00 00 20 00 00 00 00 10 00 00 00
944 : report02 : 10 08 02 00 00 00 00 00 20 00 00 00 01 10 00 00 00
945 : report03 : 10 08 02 00 00 00 00 00 20 00 00 00 02 10 00 00 00
946 : report04 : 10 08 02 00 00 00 00 00 20 00 00 00 03 10 00 00 00
947 : report05 : 10 08 02 00 00 00 00 00 20 00 00 00 04 10 00 00 00
948 : report06 : 10 08 02 00 00 00 00 00 20 00 00 00 05 10 00 00 00
949 : report07 : 10 08 02 00 00 00 00 00 20 00 00 00 06 10 00 00 00
950 : report08 : 10 08 02 00 00 00 00 00 20 00 00 00 07 10 00 00 00
951 : report09 : 10 08 02 00 00 00 00 00 20 00 00 00 08 10 00 00 00
952 : report10 : 10 08 02 00 00 00 00 00 20 00 00 00 09 10 00 00 00
953 : table01 : 10 08 00 00 00 00 00 00 20 00 00 00 0a 10 00 00 00
954 : table02 : 10 08 00 00 00 00 00 00 20 00 00 00 0b 10 00 00 00
955 : table03 : 10 08 00 00 00 00 00 00 20 00 00 00 0c 10 00 00 00
956 : table04 : 10 08 00 00 00 00 00 00 20 00 00 00 0d 10 00 00 00
957 : table05 : 10 08 00 00 00 00 00 00 20 00 00 00 0e 10 00 00 00
958 : table06 : 10 08 00 00 00 00 00 00 20 00 00 00 0f 10 00 00 00
959 : table07 : 10 08 00 00 00 00 00 00 20 00 00 00 10 10 00 00 00
960 : table08 : 10 08 00 00 00 00 00 00 20 00 00 00 11 10 00 00 00
961 : table09 : 10 08 00 00 00 00 00 00 20 00 00 00 12 10 00 00 00
962 : table10 : 10 08 00 00 00 00 00 00 20 00 00 00 13 10 00 00 00
963 : none : 10 08 00 00 00 00 00 00 20 00 00 00 15 10 00 00 00
964 : **/
965 :
966 2 : XclPTViewEx9Info::XclPTViewEx9Info() :
967 : mbReport( 0 ),
968 : mnAutoFormat( 0 ),
969 2 : mnGridLayout( 0x10 )
970 : {
971 2 : }
972 :
973 0 : void XclPTViewEx9Info::Init( const ScDPObject& rDPObj )
974 : {
975 0 : if( rDPObj.GetHeaderLayout() )
976 : {
977 0 : mbReport = 0;
978 0 : mnAutoFormat = 1;
979 0 : mnGridLayout = 0;
980 : }
981 : else
982 : {
983 : // Report1 for now
984 : // TODO : sync with autoformat indices
985 0 : mbReport = 2;
986 0 : mnAutoFormat = 1;
987 0 : mnGridLayout = 0x10;
988 : }
989 :
990 0 : const ScDPSaveData* pData = rDPObj.GetSaveData();
991 0 : if (pData)
992 : {
993 0 : const OUString* pGrandTotal = pData->GetGrandTotalName();
994 0 : if (pGrandTotal)
995 0 : maGrandTotalName = *pGrandTotal;
996 : }
997 0 : }
998 :
999 2 : XclImpStream& operator>>( XclImpStream& rStrm, XclPTViewEx9Info& rInfo )
1000 : {
1001 2 : rStrm.Ignore( 2 );
1002 2 : rInfo.mbReport = rStrm.ReaduInt32(); /// 2 for report* fmts ?
1003 2 : rStrm.Ignore( 6 );
1004 2 : rInfo.mnAutoFormat = rStrm.ReaduInt8();
1005 2 : rInfo.mnGridLayout = rStrm.ReaduInt8();
1006 2 : rInfo.maGrandTotalName = rStrm.ReadUniString();
1007 2 : return rStrm;
1008 : }
1009 :
1010 0 : XclExpStream& operator<<( XclExpStream& rStrm, const XclPTViewEx9Info& rInfo )
1011 : {
1012 : return rStrm
1013 0 : << EXC_PT_AUTOFMT_HEADER
1014 0 : << rInfo.mbReport
1015 0 : << EXC_PT_AUTOFMT_ZERO
1016 0 : << EXC_PT_AUTOFMT_FLAGS
1017 0 : << rInfo.mnAutoFormat
1018 0 : << rInfo.mnGridLayout
1019 0 : << XclExpString(rInfo.maGrandTotalName, EXC_STR_DEFAULT, EXC_PT_MAXSTRLEN);
1020 30 : }
1021 :
1022 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|