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