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

Generated by: LCOV version 1.10