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

Generated by: LCOV version 1.10