LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xlpivot.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 219 542 40.4 %
Date: 2014-11-03 Functions: 52 96 54.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10