LCOV - code coverage report
Current view: top level - sc/source/core/data - dpoutput.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 724 903 80.2 %
Date: 2014-04-11 Functions: 43 46 93.5 %
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 "scitems.hxx"
      21             : #include <svx/algitem.hxx>
      22             : #include <editeng/boxitem.hxx>
      23             : #include <editeng/brushitem.hxx>
      24             : #include <editeng/wghtitem.hxx>
      25             : #include <editeng/justifyitem.hxx>
      26             : #include <unotools/transliterationwrapper.hxx>
      27             : 
      28             : #include "dpoutput.hxx"
      29             : #include "dptabsrc.hxx"
      30             : #include "dpfilteredcache.hxx"
      31             : #include "document.hxx"
      32             : #include "patattr.hxx"
      33             : #include "docpool.hxx"
      34             : #include "markdata.hxx"
      35             : #include "attrib.hxx"
      36             : #include "formula/errorcodes.hxx"
      37             : #include "miscuno.hxx"
      38             : #include "globstr.hrc"
      39             : #include "stlpool.hxx"
      40             : #include "stlsheet.hxx"
      41             : #include "scresid.hxx"
      42             : #include "unonames.hxx"
      43             : #include "sc.hrc"
      44             : #include "stringutil.hxx"
      45             : #include "dputil.hxx"
      46             : 
      47             : #include <com/sun/star/beans/XPropertySet.hpp>
      48             : #include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
      49             : #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
      50             : #include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
      51             : #include <com/sun/star/sheet/DataPilotTableResultData.hpp>
      52             : #include <com/sun/star/sheet/MemberResultFlags.hpp>
      53             : #include <com/sun/star/sheet/TableFilterField.hpp>
      54             : #include <com/sun/star/sheet/DataResultFlags.hpp>
      55             : #include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
      56             : 
      57             : #include <vector>
      58             : 
      59             : using namespace com::sun::star;
      60             : using ::std::vector;
      61             : using ::com::sun::star::beans::XPropertySet;
      62             : using ::com::sun::star::uno::Sequence;
      63             : using ::com::sun::star::uno::UNO_QUERY;
      64             : using ::com::sun::star::uno::Reference;
      65             : using ::com::sun::star::sheet::DataPilotTablePositionData;
      66             : using ::com::sun::star::sheet::DataPilotTableResultData;
      67             : using ::com::sun::star::uno::makeAny;
      68             : using ::com::sun::star::uno::Any;
      69             : 
      70             : #define SC_DP_FRAME_INNER_BOLD      20
      71             : #define SC_DP_FRAME_OUTER_BOLD      40
      72             : 
      73             : #define SC_DP_FRAME_COLOR           Color(0,0,0) //( 0x20, 0x40, 0x68 )
      74             : 
      75             : #define SC_DPOUT_MAXLEVELS  256
      76             : 
      77       63792 : struct ScDPOutLevelData
      78             : {
      79             :     long                                nDim;
      80             :     long                                nHier;
      81             :     long                                nLevel;
      82             :     long                                nDimPos;
      83             :     sal_uInt32 mnSrcNumFmt; /// Prevailing number format used in the source data.
      84             :     uno::Sequence<sheet::MemberResult>  aResult;
      85             :     OUString                       maName;   /// Name is the internal field name.
      86             :     OUString                       maCaption; /// Caption is the name visible in the output table.
      87             :     bool                                mbHasHiddenMember:1;
      88             :     bool                                mbDataLayout:1;
      89             :     bool                                mbPageDim:1;
      90             : 
      91       63756 :     ScDPOutLevelData() :
      92       63756 :         nDim(-1), nHier(-1), nLevel(-1), nDimPos(-1), mnSrcNumFmt(0), mbHasHiddenMember(false), mbDataLayout(false), mbPageDim(false)
      93       63756 :     {}
      94             : 
      95          21 :     bool operator<(const ScDPOutLevelData& r) const
      96          42 :         { return nDimPos<r.nDimPos || ( nDimPos==r.nDimPos && nHier<r.nHier ) ||
      97          30 :             ( nDimPos==r.nDimPos && nHier==r.nHier && nLevel<r.nLevel ); }
      98             : 
      99          12 :     void Swap(ScDPOutLevelData& r)
     100          12 :         { ScDPOutLevelData aTemp; aTemp = r; r = *this; *this = aTemp; }
     101             : 
     102             :     //! bug (73840) in uno::Sequence - copy and then assign doesn't work!
     103             : };
     104             : 
     105             : namespace {
     106             : 
     107         232 : bool lcl_compareColfuc ( SCCOL i,  SCCOL j) { return (i<j); }
     108         310 : bool lcl_compareRowfuc ( SCROW i,  SCROW j) { return (i<j); }
     109             : 
     110         187 : class ScDPOutputImpl
     111             : {
     112             :     ScDocument*         mpDoc;
     113             :     sal_uInt16          mnTab;
     114             :     ::std::vector< bool > mbNeedLineCols;
     115             :     ::std::vector< SCCOL > mnCols;
     116             : 
     117             :     ::std::vector< bool > mbNeedLineRows;
     118             :     ::std::vector< SCROW > mnRows;
     119             : 
     120             :     SCCOL   mnTabStartCol;
     121             :     SCROW   mnTabStartRow;
     122             : 
     123             :     SCCOL   mnDataStartCol;
     124             :     SCROW   mnDataStartRow;
     125             :     SCCOL   mnTabEndCol;
     126             :     SCROW   mnTabEndRow;
     127             : 
     128             : public:
     129             :     ScDPOutputImpl( ScDocument* pDoc, sal_uInt16 nTab,
     130             :         SCCOL   nTabStartCol,
     131             :         SCROW   nTabStartRow,
     132             :         SCCOL nDataStartCol,
     133             :         SCROW nDataStartRow,
     134             :         SCCOL nTabEndCol,
     135             :         SCROW nTabEndRow );
     136             :     bool AddRow( SCROW nRow );
     137             :     bool AddCol( SCCOL nCol );
     138             : 
     139             :     void OutputDataArea();
     140             :     void OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bHori = false );
     141             : 
     142             : };
     143             : 
     144          82 : void ScDPOutputImpl::OutputDataArea()
     145             : {
     146          82 :     AddRow( mnDataStartRow );
     147          82 :     AddCol( mnDataStartCol );
     148             : 
     149          82 :     mnCols.push_back( mnTabEndCol+1); //set last row bottom
     150          82 :     mnRows.push_back( mnTabEndRow+1); //set last col bottom
     151             : 
     152          82 :     bool bAllRows = ( ( mnTabEndRow - mnDataStartRow + 2 ) == (SCROW) mnRows.size() );
     153             : 
     154          82 :     std::sort( mnCols.begin(), mnCols.end(), lcl_compareColfuc );
     155          82 :     std::sort( mnRows.begin(), mnRows.end(), lcl_compareRowfuc );
     156             : 
     157         216 :     for( SCCOL nCol = 0; nCol < (SCCOL)mnCols.size()-1; nCol ++ )
     158             :     {
     159         134 :         if ( !bAllRows )
     160             :         {
     161          96 :             if ( nCol < (SCCOL)mnCols.size()-2)
     162             :             {
     163          71 :                 for ( SCROW i = nCol%2; i < (SCROW)mnRows.size()-2; i +=2 )
     164          37 :                     OutputBlockFrame( mnCols[nCol], mnRows[i], mnCols[nCol+1]-1, mnRows[i+1]-1 );
     165          34 :                 if ( mnRows.size()>=2 )
     166          34 :                     OutputBlockFrame(  mnCols[nCol], mnRows[mnRows.size()-2], mnCols[nCol+1]-1, mnRows[mnRows.size()-1]-1 );
     167             :             }
     168             :             else
     169             :             {
     170         203 :                 for ( SCROW i = 0 ; i < (SCROW)mnRows.size()-1; i++ )
     171         141 :                     OutputBlockFrame(  mnCols[nCol], mnRows[i], mnCols[nCol+1]-1,  mnRows[i+1]-1 );
     172             :             }
     173             :         }
     174             :         else
     175          38 :             OutputBlockFrame( mnCols[nCol], mnRows.front(), mnCols[nCol+1]-1, mnRows.back()-1, bAllRows );
     176             :     }
     177             :     //out put rows area outer framer
     178          82 :     if ( mnTabStartCol != mnDataStartCol )
     179             :     {
     180          67 :         if ( mnTabStartRow != mnDataStartRow )
     181          67 :             OutputBlockFrame( mnTabStartCol, mnTabStartRow, mnDataStartCol-1, mnDataStartRow-1 );
     182          67 :         OutputBlockFrame( mnTabStartCol, mnDataStartRow, mnDataStartCol-1, mnTabEndRow );
     183             :     }
     184             :     //out put cols area outer framer
     185          82 :     OutputBlockFrame( mnDataStartCol, mnTabStartRow, mnTabEndCol, mnDataStartRow-1 );
     186          82 : }
     187             : 
     188         187 : ScDPOutputImpl::ScDPOutputImpl( ScDocument* pDoc, sal_uInt16 nTab,
     189             :         SCCOL   nTabStartCol,
     190             :         SCROW   nTabStartRow,
     191             :         SCCOL nDataStartCol,
     192             :         SCROW nDataStartRow,
     193             :         SCCOL nTabEndCol,
     194             :         SCROW nTabEndRow ):
     195             :     mpDoc( pDoc ),
     196             :     mnTab( nTab ),
     197             :     mnTabStartCol( nTabStartCol ),
     198             :     mnTabStartRow( nTabStartRow ),
     199             :     mnDataStartCol ( nDataStartCol ),
     200             :     mnDataStartRow ( nDataStartRow ),
     201             :     mnTabEndCol(  nTabEndCol ),
     202         187 :     mnTabEndRow(  nTabEndRow )
     203             : {
     204         187 :     mbNeedLineCols.resize( nTabEndCol-nDataStartCol+1, false );
     205         187 :     mbNeedLineRows.resize( nTabEndRow-nDataStartRow+1, false );
     206             : 
     207         187 : }
     208             : 
     209         194 : bool ScDPOutputImpl::AddRow( SCROW nRow )
     210             : {
     211         194 :     if ( !mbNeedLineRows[ nRow - mnDataStartRow ] )
     212             :     {
     213         178 :         mbNeedLineRows[ nRow - mnDataStartRow ] = true;
     214         178 :         mnRows.push_back( nRow );
     215         178 :         return true;
     216             :     }
     217             :     else
     218          16 :         return false;
     219             : }
     220             : 
     221         138 : bool ScDPOutputImpl::AddCol( SCCOL nCol )
     222             : {
     223             : 
     224         138 :     if ( !mbNeedLineCols[ nCol - mnDataStartCol ] )
     225             :     {
     226         134 :         mbNeedLineCols[ nCol - mnDataStartCol ] = true;
     227         134 :         mnCols.push_back( nCol );
     228         134 :         return true;
     229             :     }
     230             :     else
     231           4 :         return false;
     232             : }
     233             : 
     234         743 : void ScDPOutputImpl::OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bHori )
     235             : {
     236         743 :     Color color = SC_DP_FRAME_COLOR;
     237         743 :     ::editeng::SvxBorderLine aLine( &color, SC_DP_FRAME_INNER_BOLD );
     238         743 :     ::editeng::SvxBorderLine aOutLine( &color, SC_DP_FRAME_OUTER_BOLD );
     239             : 
     240         743 :     SvxBoxItem aBox( ATTR_BORDER );
     241             : 
     242         743 :     if ( nStartCol == mnTabStartCol )
     243         313 :         aBox.SetLine(&aOutLine, BOX_LINE_LEFT);
     244             :     else
     245         430 :         aBox.SetLine(&aLine, BOX_LINE_LEFT);
     246             : 
     247         743 :     if ( nStartRow == mnTabStartRow )
     248         186 :         aBox.SetLine(&aOutLine, BOX_LINE_TOP);
     249             :     else
     250         557 :         aBox.SetLine(&aLine, BOX_LINE_TOP);
     251             : 
     252         743 :     if ( nEndCol == mnTabEndCol ) //bottom row
     253         364 :         aBox.SetLine(&aOutLine, BOX_LINE_RIGHT);
     254             :     else
     255         379 :         aBox.SetLine(&aLine,  BOX_LINE_RIGHT);
     256             : 
     257         743 :      if ( nEndRow == mnTabEndRow ) //bottom
     258         264 :         aBox.SetLine(&aOutLine,  BOX_LINE_BOTTOM);
     259             :     else
     260         479 :         aBox.SetLine(&aLine,  BOX_LINE_BOTTOM);
     261             : 
     262             : 
     263        1486 :     SvxBoxInfoItem aBoxInfo( ATTR_BORDER_INNER );
     264         743 :     aBoxInfo.SetValid(VALID_VERT,false );
     265         743 :     if ( bHori )
     266             :     {
     267          38 :         aBoxInfo.SetValid(VALID_HORI,true);
     268          38 :         aBoxInfo.SetLine( &aLine, BOXINFO_LINE_HORI );
     269             :     }
     270             :     else
     271         705 :         aBoxInfo.SetValid(VALID_HORI,false );
     272             : 
     273         743 :     aBoxInfo.SetValid(VALID_DISTANCE,false);
     274             : 
     275        1486 :     mpDoc->ApplyFrameAreaTab( ScRange(  nStartCol, nStartRow, mnTab, nEndCol, nEndRow , mnTab ), &aBox, &aBoxInfo );
     276             : 
     277         743 : }
     278             : 
     279        1067 : void lcl_SetStyleById( ScDocument* pDoc, SCTAB nTab,
     280             :                     SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
     281             :                     sal_uInt16 nStrId )
     282             : {
     283        1067 :     if ( nCol1 > nCol2 || nRow1 > nRow2 )
     284             :     {
     285             :         OSL_FAIL("SetStyleById: invalid range");
     286        1067 :         return;
     287             :     }
     288             : 
     289        1067 :     OUString aStyleName = ScGlobal::GetRscString( nStrId );
     290        1067 :     ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool();
     291        1067 :     ScStyleSheet* pStyle = (ScStyleSheet*) pStlPool->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
     292        1067 :     if (!pStyle)
     293             :     {
     294             :         //  create new style (was in ScPivot::SetStyle)
     295             : 
     296             :         pStyle = (ScStyleSheet*) &pStlPool->Make( aStyleName, SFX_STYLE_FAMILY_PARA,
     297         170 :                                                     SFXSTYLEBIT_USERDEF );
     298         170 :         pStyle->SetParent( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
     299         170 :         SfxItemSet& rSet = pStyle->GetItemSet();
     300         170 :         if ( nStrId==STR_PIVOT_STYLE_RESULT || nStrId==STR_PIVOT_STYLE_TITLE )
     301          52 :             rSet.Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
     302         170 :         if ( nStrId==STR_PIVOT_STYLE_CATEGORY || nStrId==STR_PIVOT_STYLE_TITLE )
     303          53 :             rSet.Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_LEFT, ATTR_HOR_JUSTIFY ) );
     304             :     }
     305             : 
     306        1067 :     pDoc->ApplyStyleAreaTab( nCol1, nRow1, nCol2, nRow2, nTab, *pStyle );
     307             : }
     308             : 
     309         149 : void lcl_SetFrame( ScDocument* pDoc, SCTAB nTab,
     310             :                     SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
     311             :                     sal_uInt16 nWidth )
     312             : {
     313         149 :     ::editeng::SvxBorderLine aLine(0, nWidth, table::BorderLineStyle::SOLID);
     314         149 :     SvxBoxItem aBox( ATTR_BORDER );
     315         149 :     aBox.SetLine(&aLine, BOX_LINE_LEFT);
     316         149 :     aBox.SetLine(&aLine, BOX_LINE_TOP);
     317         149 :     aBox.SetLine(&aLine, BOX_LINE_RIGHT);
     318         149 :     aBox.SetLine(&aLine, BOX_LINE_BOTTOM);
     319         298 :     SvxBoxInfoItem aBoxInfo( ATTR_BORDER_INNER );
     320         149 :     aBoxInfo.SetValid(VALID_HORI,false);
     321         149 :     aBoxInfo.SetValid(VALID_VERT,false);
     322         149 :     aBoxInfo.SetValid(VALID_DISTANCE,false);
     323             : 
     324         298 :     pDoc->ApplyFrameAreaTab( ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab ), &aBox, &aBoxInfo );
     325         149 : }
     326             : 
     327          46 : void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
     328             :                             const uno::Reference<sheet::XDataPilotMemberResults>& xLevRes,
     329             :                             const uno::Reference<container::XIndexAccess>& xDims )
     330             : {
     331          46 :     if ( rFormats )
     332           1 :         return;                         // already set
     333             : 
     334             :     //  xLevRes is from the data layout dimension
     335             :     //! use result sequence from ScDPOutLevelData!
     336             : 
     337          46 :     uno::Sequence<sheet::MemberResult> aResult = xLevRes->getResults();
     338             : 
     339          46 :     long nSize = aResult.getLength();
     340          46 :     if (!nSize)
     341           0 :         return;
     342             : 
     343             :     //  get names/formats for all data dimensions
     344             :     //! merge this with the loop to collect ScDPOutLevelData?
     345             : 
     346       11822 :     OUString aDataNames[SC_DPOUT_MAXLEVELS];
     347             :     sal_uInt32 nDataFormats[SC_DPOUT_MAXLEVELS];
     348          46 :     long nDataCount = 0;
     349          46 :     long nDimCount = xDims->getCount();
     350         242 :     for (long nDim=0; nDim<nDimCount; nDim++)
     351             :     {
     352             :         uno::Reference<uno::XInterface> xDim =
     353         196 :                 ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
     354         392 :         uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
     355         392 :         uno::Reference<container::XNamed> xDimName( xDim, uno::UNO_QUERY );
     356         196 :         if ( xDimProp.is() && xDimName.is() )
     357             :         {
     358             :             sheet::DataPilotFieldOrientation eDimOrient =
     359             :                 (sheet::DataPilotFieldOrientation) ScUnoHelpFunctions::GetEnumProperty(
     360             :                     xDimProp, OUString(SC_UNO_DP_ORIENTATION),
     361         196 :                     sheet::DataPilotFieldOrientation_HIDDEN );
     362         196 :             if ( eDimOrient == sheet::DataPilotFieldOrientation_DATA )
     363             :             {
     364          52 :                 aDataNames[nDataCount] = xDimName->getName();
     365             :                 long nFormat = ScUnoHelpFunctions::GetLongProperty(
     366             :                                         xDimProp,
     367          52 :                                         OUString(SC_UNONAME_NUMFMT) );
     368          52 :                 nDataFormats[nDataCount] = nFormat;
     369          52 :                 ++nDataCount;
     370             :             }
     371             :         }
     372         196 :     }
     373             : 
     374          46 :     if (!nDataCount)
     375           1 :         return;
     376             : 
     377          45 :     const sheet::MemberResult* pArray = aResult.getConstArray();
     378             : 
     379          90 :     OUString aName;
     380          45 :     sal_uInt32* pNumFmt = new sal_uInt32[nSize];
     381          45 :     if (nDataCount == 1)
     382             :     {
     383             :         //  only one data dimension -> use its numberformat everywhere
     384          38 :         long nFormat = nDataFormats[0];
     385         249 :         for (long nPos=0; nPos<nSize; nPos++)
     386         211 :             pNumFmt[nPos] = nFormat;
     387             :     }
     388             :     else
     389             :     {
     390          29 :         for (long nPos=0; nPos<nSize; nPos++)
     391             :         {
     392             :             //  if CONTINUE bit is set, keep previous name
     393             :             //! keep number format instead!
     394          22 :             if ( !(pArray[nPos].Flags & sheet::MemberResultFlags::CONTINUE) )
     395          22 :                 aName = pArray[nPos].Name;
     396             : 
     397          22 :             sal_uInt32 nFormat = 0;
     398          33 :             for (long i=0; i<nDataCount; i++)
     399          33 :                 if (aName == aDataNames[i])         //! search more efficiently?
     400             :                 {
     401          22 :                     nFormat = nDataFormats[i];
     402          22 :                     break;
     403             :                 }
     404          22 :             pNumFmt[nPos] = nFormat;
     405             :         }
     406             :     }
     407             : 
     408          45 :     rFormats = pNumFmt;
     409          90 :     rCount = nSize;
     410             : }
     411             : 
     412          37 : sal_uInt32 lcl_GetFirstNumberFormat( const uno::Reference<container::XIndexAccess>& xDims )
     413             : {
     414          37 :     long nDimCount = xDims->getCount();
     415         135 :     for (long nDim=0; nDim<nDimCount; nDim++)
     416             :     {
     417             :         uno::Reference<uno::XInterface> xDim =
     418         125 :                 ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
     419         223 :         uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
     420         125 :         if ( xDimProp.is() )
     421             :         {
     422             :             sheet::DataPilotFieldOrientation eDimOrient =
     423             :                 (sheet::DataPilotFieldOrientation) ScUnoHelpFunctions::GetEnumProperty(
     424             :                     xDimProp, OUString(SC_UNO_DP_ORIENTATION),
     425         125 :                     sheet::DataPilotFieldOrientation_HIDDEN );
     426         125 :             if ( eDimOrient == sheet::DataPilotFieldOrientation_DATA )
     427             :             {
     428             :                 long nFormat = ScUnoHelpFunctions::GetLongProperty(
     429             :                                         xDimProp,
     430          27 :                                         OUString(SC_UNONAME_NUMFMT) );
     431             : 
     432          27 :                 return nFormat;     // use format from first found data dimension
     433             :             }
     434             :         }
     435          98 :     }
     436             : 
     437          10 :     return 0;       // none found
     438             : }
     439             : 
     440         249 : void lcl_SortFields( ScDPOutLevelData* pFields, long nFieldCount )
     441             : {
     442         268 :     for (long i=0; i+1<nFieldCount; i++)
     443             :     {
     444          40 :         for (long j=0; j+i+1<nFieldCount; j++)
     445          21 :             if ( pFields[j+1] < pFields[j] )
     446          12 :                 pFields[j].Swap( pFields[j+1] );
     447             :     }
     448         249 : }
     449             : 
     450         167 : bool lcl_MemberEmpty( const uno::Sequence<sheet::MemberResult>& rSeq )
     451             : {
     452             :     //  used to skip levels that have no members
     453             : 
     454         167 :     long nLen = rSeq.getLength();
     455         167 :     const sheet::MemberResult* pArray = rSeq.getConstArray();
     456         383 :     for (long i=0; i<nLen; i++)
     457         344 :         if (pArray[i].Flags & sheet::MemberResultFlags::HASMEMBER)
     458         128 :             return false;
     459             : 
     460          39 :     return true;    // no member data -> empty
     461             : }
     462             : 
     463             : /**
     464             :  * Get visible page dimension members as results, except that, if all
     465             :  * members are visible, then this function returns empty result.
     466             :  */
     467          23 : uno::Sequence<sheet::MemberResult> getVisiblePageMembersAsResults( const uno::Reference<uno::XInterface>& xLevel )
     468             : {
     469          23 :     if (!xLevel.is())
     470           0 :         return uno::Sequence<sheet::MemberResult>();
     471             : 
     472          23 :     uno::Reference<sheet::XMembersSupplier> xMSupplier(xLevel, UNO_QUERY);
     473          23 :     if (!xMSupplier.is())
     474           0 :         return uno::Sequence<sheet::MemberResult>();
     475             : 
     476          46 :     uno::Reference<container::XNameAccess> xNA = xMSupplier->getMembers();
     477          23 :     if (!xNA.is())
     478           0 :         return uno::Sequence<sheet::MemberResult>();
     479             : 
     480          46 :     std::vector<sheet::MemberResult> aRes;
     481          46 :     uno::Sequence<OUString> aNames = xNA->getElementNames();
     482         126 :     for (sal_Int32 i = 0; i < aNames.getLength(); ++i)
     483             :     {
     484         103 :         const OUString& rName = aNames[i];
     485         103 :         xNA->getByName(rName);
     486             : 
     487         103 :         uno::Reference<beans::XPropertySet> xMemPS(xNA->getByName(rName), UNO_QUERY);
     488         103 :         if (!xMemPS.is())
     489           0 :             continue;
     490             : 
     491         206 :         OUString aCaption = ScUnoHelpFunctions::GetStringProperty(xMemPS, SC_UNO_DP_LAYOUTNAME, OUString());
     492         103 :         if (aCaption.isEmpty())
     493         103 :             aCaption = rName;
     494             : 
     495         103 :         bool bVisible = ScUnoHelpFunctions::GetBoolProperty(xMemPS, SC_UNO_DP_ISVISIBLE, false);
     496             : 
     497         103 :         if (bVisible)
     498          95 :             aRes.push_back(sheet::MemberResult(rName, aCaption, 0));
     499         103 :     }
     500             : 
     501          23 :     if (aNames.getLength() == static_cast<sal_Int32>(aRes.size()))
     502             :         // All members are visible.  Return empty result.
     503          19 :         return uno::Sequence<sheet::MemberResult>();
     504             : 
     505          27 :     return ScUnoHelpFunctions::VectorToSequence(aRes);
     506             : }
     507             : 
     508             : }
     509             : 
     510          83 : ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsSupplier>& xSrc,
     511             :                         const ScAddress& rPos, bool bFilter ) :
     512             :     pDoc( pD ),
     513             :     xSource( xSrc ),
     514             :     aStartPos( rPos ),
     515             :     pColNumFmt( NULL ),
     516             :     pRowNumFmt( NULL ),
     517             :     nColFmtCount( 0 ),
     518             :     nRowFmtCount( 0 ),
     519             :     nSingleNumFmt( 0 ),
     520             :     nColCount(0),
     521             :     nRowCount(0),
     522             :     nHeaderSize(0),
     523             :     bDoFilter(bFilter),
     524             :     bResultsError(false),
     525             :     mbHasDataLayout(false),
     526             :     bSizesValid(false),
     527             :     bSizeOverflow(false),
     528          83 :     mbHeaderLayout(false)
     529             : {
     530          83 :     nTabStartCol = nMemberStartCol = nDataStartCol = nTabEndCol = 0;
     531          83 :     nTabStartRow = nMemberStartRow = nDataStartRow = nTabEndRow = 0;
     532             : 
     533          83 :     pColFields  = new ScDPOutLevelData[SC_DPOUT_MAXLEVELS];
     534          83 :     pRowFields  = new ScDPOutLevelData[SC_DPOUT_MAXLEVELS];
     535          83 :     pPageFields = new ScDPOutLevelData[SC_DPOUT_MAXLEVELS];
     536          83 :     nColFieldCount = 0;
     537          83 :     nRowFieldCount = 0;
     538          83 :     nPageFieldCount = 0;
     539             : 
     540          83 :     uno::Reference<sheet::XDataPilotResults> xResult( xSource, uno::UNO_QUERY );
     541          83 :     if ( xSource.is() && xResult.is() )
     542             :     {
     543             :         //  get dimension results:
     544             : 
     545             :         uno::Reference<container::XIndexAccess> xDims =
     546          83 :                 new ScNameToIndexAccess( xSource->getDimensions() );
     547          83 :         long nDimCount = xDims->getCount();
     548         500 :         for (long nDim=0; nDim<nDimCount; nDim++)
     549             :         {
     550             :             uno::Reference<uno::XInterface> xDim =
     551         417 :                     ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
     552         834 :             uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
     553         834 :             uno::Reference<sheet::XHierarchiesSupplier> xDimSupp( xDim, uno::UNO_QUERY );
     554         417 :             if ( xDimProp.is() && xDimSupp.is() )
     555             :             {
     556             :                 sheet::DataPilotFieldOrientation eDimOrient =
     557             :                     (sheet::DataPilotFieldOrientation) ScUnoHelpFunctions::GetEnumProperty(
     558             :                         xDimProp, OUString(SC_UNO_DP_ORIENTATION),
     559         417 :                         sheet::DataPilotFieldOrientation_HIDDEN );
     560             :                 long nDimPos = ScUnoHelpFunctions::GetLongProperty( xDimProp,
     561         417 :                         OUString(SC_UNO_DP_POSITION) );
     562             :                 bool bIsDataLayout = ScUnoHelpFunctions::GetBoolProperty(
     563         417 :                     xDimProp, OUString(SC_UNO_DP_ISDATALAYOUT));
     564             :                 bool bHasHiddenMember = ScUnoHelpFunctions::GetBoolProperty(
     565         417 :                     xDimProp, OUString(SC_UNO_DP_HAS_HIDDEN_MEMBER));
     566             :                 sal_Int32 nNumFmt = ScUnoHelpFunctions::GetLongProperty(
     567         417 :                     xDimProp, SC_UNO_DP_NUMBERFO, 0);
     568             : 
     569         417 :                 if ( eDimOrient != sheet::DataPilotFieldOrientation_HIDDEN )
     570             :                 {
     571             :                     uno::Reference<container::XIndexAccess> xHiers =
     572         269 :                             new ScNameToIndexAccess( xDimSupp->getHierarchies() );
     573             :                     long nHierarchy = ScUnoHelpFunctions::GetLongProperty(
     574             :                                             xDimProp,
     575         269 :                                             OUString(SC_UNO_DP_USEDHIERARCHY) );
     576         269 :                     if ( nHierarchy >= xHiers->getCount() )
     577           0 :                         nHierarchy = 0;
     578             : 
     579             :                     uno::Reference<uno::XInterface> xHier =
     580             :                             ScUnoHelpFunctions::AnyToInterface(
     581         538 :                                                 xHiers->getByIndex(nHierarchy) );
     582         538 :                     uno::Reference<sheet::XLevelsSupplier> xHierSupp( xHier, uno::UNO_QUERY );
     583         269 :                     if ( xHierSupp.is() )
     584             :                     {
     585             :                         uno::Reference<container::XIndexAccess> xLevels =
     586         269 :                                 new ScNameToIndexAccess( xHierSupp->getLevels() );
     587         269 :                         long nLevCount = xLevels->getCount();
     588         538 :                         for (long nLev=0; nLev<nLevCount; nLev++)
     589             :                         {
     590             :                             uno::Reference<uno::XInterface> xLevel =
     591             :                                         ScUnoHelpFunctions::AnyToInterface(
     592         269 :                                                             xLevels->getByIndex(nLev) );
     593         538 :                             uno::Reference<container::XNamed> xLevNam( xLevel, uno::UNO_QUERY );
     594             :                             uno::Reference<sheet::XDataPilotMemberResults> xLevRes(
     595         538 :                                     xLevel, uno::UNO_QUERY );
     596         269 :                             if ( xLevNam.is() && xLevRes.is() )
     597             :                             {
     598         269 :                                 OUString aName = xLevNam->getName();
     599         538 :                                 Reference<XPropertySet> xPropSet(xLevel, UNO_QUERY);
     600             :                                 // Caption equals the field name by default.
     601             :                                 // #i108948# use ScUnoHelpFunctions::GetStringProperty, because
     602             :                                 // LayoutName is new and may not be present in external implementation
     603             :                                 OUString aCaption = ScUnoHelpFunctions::GetStringProperty( xPropSet,
     604         538 :                                     OUString(SC_UNO_DP_LAYOUTNAME), aName );
     605             : 
     606         269 :                                 bool bRowFieldHasMember = false;
     607         269 :                                 switch ( eDimOrient )
     608             :                                 {
     609             :                                     case sheet::DataPilotFieldOrientation_COLUMN:
     610          45 :                                         pColFields[nColFieldCount].nDim    = nDim;
     611          45 :                                         pColFields[nColFieldCount].nHier   = nHierarchy;
     612          45 :                                         pColFields[nColFieldCount].nLevel  = nLev;
     613          45 :                                         pColFields[nColFieldCount].nDimPos = nDimPos;
     614          45 :                                         pColFields[nColFieldCount].aResult = xLevRes->getResults();
     615          45 :                                         pColFields[nColFieldCount].mnSrcNumFmt = nNumFmt;
     616          45 :                                         pColFields[nColFieldCount].maName  = aName;
     617          45 :                                         pColFields[nColFieldCount].maCaption= aCaption;
     618          45 :                                         pColFields[nColFieldCount].mbHasHiddenMember = bHasHiddenMember;
     619          45 :                                         pColFields[nColFieldCount].mbDataLayout = bIsDataLayout;
     620          45 :                                         if (!lcl_MemberEmpty(pColFields[nColFieldCount].aResult))
     621          45 :                                             ++nColFieldCount;
     622          45 :                                         break;
     623             :                                     case sheet::DataPilotFieldOrientation_ROW:
     624         122 :                                         pRowFields[nRowFieldCount].nDim    = nDim;
     625         122 :                                         pRowFields[nRowFieldCount].nHier   = nHierarchy;
     626         122 :                                         pRowFields[nRowFieldCount].nLevel  = nLev;
     627         122 :                                         pRowFields[nRowFieldCount].nDimPos = nDimPos;
     628         122 :                                         pRowFields[nRowFieldCount].aResult = xLevRes->getResults();
     629         122 :                                         pRowFields[nRowFieldCount].mnSrcNumFmt = nNumFmt;
     630         122 :                                         pRowFields[nRowFieldCount].maName  = aName;
     631         122 :                                         pRowFields[nRowFieldCount].maCaption= aCaption;
     632         122 :                                         pRowFields[nRowFieldCount].mbHasHiddenMember = bHasHiddenMember;
     633         122 :                                         pRowFields[nRowFieldCount].mbDataLayout = bIsDataLayout;
     634         122 :                                         if (!lcl_MemberEmpty(pRowFields[nRowFieldCount].aResult))
     635             :                                         {
     636          83 :                                             ++nRowFieldCount;
     637          83 :                                             bRowFieldHasMember = true;
     638             :                                         }
     639         122 :                                         break;
     640             :                                     case sheet::DataPilotFieldOrientation_PAGE:
     641          23 :                                         pPageFields[nPageFieldCount].nDim    = nDim;
     642          23 :                                         pPageFields[nPageFieldCount].nHier   = nHierarchy;
     643          23 :                                         pPageFields[nPageFieldCount].nLevel  = nLev;
     644          23 :                                         pPageFields[nPageFieldCount].nDimPos = nDimPos;
     645          23 :                                         pPageFields[nPageFieldCount].aResult = getVisiblePageMembersAsResults(xLevel);
     646          23 :                                         pPageFields[nPageFieldCount].mnSrcNumFmt = nNumFmt;
     647          23 :                                         pPageFields[nPageFieldCount].maName  = aName;
     648          23 :                                         pPageFields[nPageFieldCount].maCaption= aCaption;
     649          23 :                                         pPageFields[nPageFieldCount].mbHasHiddenMember = bHasHiddenMember;
     650          23 :                                         pPageFields[nPageFieldCount].mbPageDim = true;
     651             :                                         // no check on results for page fields
     652          23 :                                         ++nPageFieldCount;
     653          23 :                                         break;
     654             :                                     default:
     655             :                                     {
     656             :                                         // added to avoid warnings
     657             :                                     }
     658             :                                 }
     659             : 
     660             :                                 // get number formats from data dimensions
     661         269 :                                 if ( bIsDataLayout )
     662             :                                 {
     663          46 :                                     if (bRowFieldHasMember)
     664           6 :                                         mbHasDataLayout = true;
     665             : 
     666             :                                     OSL_ENSURE( nLevCount == 1, "data layout: multiple levels?" );
     667          46 :                                     if ( eDimOrient == sheet::DataPilotFieldOrientation_COLUMN )
     668           1 :                                         lcl_FillNumberFormats( pColNumFmt, nColFmtCount, xLevRes, xDims );
     669          45 :                                     else if ( eDimOrient == sheet::DataPilotFieldOrientation_ROW )
     670          45 :                                         lcl_FillNumberFormats( pRowNumFmt, nRowFmtCount, xLevRes, xDims );
     671         269 :                                 }
     672             :                             }
     673         538 :                         }
     674         269 :                     }
     675             :                 }
     676         148 :                 else if ( bIsDataLayout )
     677             :                 {
     678             :                     // data layout dimension is hidden (allowed if there is only one data dimension)
     679             :                     // -> use the number format from the first data dimension for all results
     680             : 
     681          37 :                     nSingleNumFmt = lcl_GetFirstNumberFormat( xDims );
     682             :                 }
     683             :             }
     684         417 :         }
     685          83 :         lcl_SortFields( pColFields, nColFieldCount );
     686          83 :         lcl_SortFields( pRowFields, nRowFieldCount );
     687          83 :         lcl_SortFields( pPageFields, nPageFieldCount );
     688             : 
     689             :         //  get data results:
     690             : 
     691             :         try
     692             :         {
     693          83 :             aData = xResult->getResults();
     694             :         }
     695           0 :         catch (const uno::RuntimeException&)
     696             :         {
     697           0 :             bResultsError = true;
     698          83 :         }
     699             :     }
     700             : 
     701             :     // get "DataDescription" property (may be missing in external sources)
     702             : 
     703          83 :     uno::Reference<beans::XPropertySet> xSrcProp( xSource, uno::UNO_QUERY );
     704          83 :     if ( xSrcProp.is() )
     705             :     {
     706             :         try
     707             :         {
     708          83 :             uno::Any aAny = xSrcProp->getPropertyValue(
     709          83 :                     OUString(SC_UNO_DP_DATADESC) );
     710         166 :             OUString aUStr;
     711          83 :             aAny >>= aUStr;
     712         166 :             aDataDescription = aUStr;
     713             :         }
     714           0 :         catch(const uno::Exception&)
     715             :         {
     716             :         }
     717          83 :     }
     718          83 : }
     719             : 
     720         166 : ScDPOutput::~ScDPOutput()
     721             : {
     722          83 :     delete[] pColFields;
     723          83 :     delete[] pRowFields;
     724          83 :     delete[] pPageFields;
     725             : 
     726          83 :     delete[] pColNumFmt;
     727          83 :     delete[] pRowNumFmt;
     728          83 : }
     729             : 
     730         148 : void ScDPOutput::SetPosition( const ScAddress& rPos )
     731             : {
     732         148 :     aStartPos = rPos;
     733         148 :     bSizesValid = bSizeOverflow = false;
     734         148 : }
     735             : 
     736        1379 : void ScDPOutput::DataCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const sheet::DataResult& rData )
     737             : {
     738        1379 :     long nFlags = rData.Flags;
     739        1379 :     if ( nFlags & sheet::DataResultFlags::ERROR )
     740             :     {
     741           0 :         pDoc->SetError( nCol, nRow, nTab, errNoValue );
     742             :     }
     743        1379 :     else if ( nFlags & sheet::DataResultFlags::HASDATA )
     744             :     {
     745         695 :         pDoc->SetValue( nCol, nRow, nTab, rData.Value );
     746             : 
     747             :         //  use number formats from source
     748             : 
     749             :         OSL_ENSURE( bSizesValid, "DataCell: !bSizesValid" );
     750         695 :         sal_uInt32 nFormat = 0;
     751         695 :         bool bApplyFormat = false;
     752         695 :         if ( pColNumFmt )
     753             :         {
     754           6 :             if ( nCol >= nDataStartCol )
     755             :             {
     756           6 :                 long nIndex = nCol - nDataStartCol;
     757           6 :                 if ( nIndex < nColFmtCount )
     758             :                 {
     759           6 :                     nFormat = pColNumFmt[nIndex];
     760           6 :                     bApplyFormat = true;
     761             :                 }
     762             :             }
     763             :         }
     764         689 :         else if ( pRowNumFmt )
     765             :         {
     766         362 :             if ( nRow >= nDataStartRow )
     767             :             {
     768         362 :                 long nIndex = nRow - nDataStartRow;
     769         362 :                 if ( nIndex < nRowFmtCount )
     770             :                 {
     771         362 :                     nFormat = pRowNumFmt[nIndex];
     772         362 :                     bApplyFormat = true;
     773             :                 }
     774             :             }
     775             :         }
     776         327 :         else if ( nSingleNumFmt != 0 )
     777             :         {
     778           0 :             nFormat = nSingleNumFmt;        // single format is used everywhere
     779           0 :             bApplyFormat = true;
     780             :         }
     781             : 
     782         695 :         if (bApplyFormat)
     783         368 :             pDoc->ApplyAttr(nCol, nRow, nTab, SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
     784             :     }
     785             :     //  SubTotal formatting is controlled by headers
     786        1379 : }
     787             : 
     788         700 : void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
     789             :                              const sheet::MemberResult& rData, bool bColHeader, long nLevel )
     790             : {
     791         700 :     long nFlags = rData.Flags;
     792             : 
     793         700 :     if ( nFlags & sheet::MemberResultFlags::HASMEMBER )
     794             :     {
     795         649 :         bool bNumeric = (nFlags & sheet::MemberResultFlags::NUMERIC) != 0;
     796         649 :         ScSetStringParam aParam;
     797         649 :         if (bNumeric)
     798         332 :             aParam.setNumericInput();
     799             :         else
     800         317 :             aParam.setTextInput();
     801             : 
     802         649 :         pDoc->SetString(nCol, nRow, nTab, rData.Caption, &aParam);
     803             :     }
     804             : 
     805         700 :     if ( nFlags & sheet::MemberResultFlags::SUBTOTAL )
     806             :     {
     807             :         ScDPOutputImpl outputimp( pDoc, nTab,
     808             :             nTabStartCol, nTabStartRow,
     809         105 :             nDataStartCol, nDataStartRow, nTabEndCol, nTabEndRow );
     810             :         //! limit frames to horizontal or vertical?
     811         105 :         if (bColHeader)
     812             :         {
     813          40 :             outputimp.OutputBlockFrame( nCol,nMemberStartRow+(SCROW)nLevel, nCol,nDataStartRow-1 );
     814             : 
     815             :             lcl_SetStyleById( pDoc,nTab, nCol,nMemberStartRow+(SCROW)nLevel, nCol,nDataStartRow-1,
     816          40 :                                     STR_PIVOT_STYLE_TITLE );
     817             :             lcl_SetStyleById( pDoc,nTab, nCol,nDataStartRow, nCol,nTabEndRow,
     818          40 :                                     STR_PIVOT_STYLE_RESULT );
     819             :         }
     820             :         else
     821             :         {
     822          65 :             outputimp.OutputBlockFrame( nMemberStartCol+(SCCOL)nLevel,nRow, nDataStartCol-1,nRow );
     823             :             lcl_SetStyleById( pDoc,nTab, nMemberStartCol+(SCCOL)nLevel,nRow, nDataStartCol-1,nRow,
     824          65 :                                     STR_PIVOT_STYLE_TITLE );
     825             :             lcl_SetStyleById( pDoc,nTab, nDataStartCol,nRow, nTabEndCol,nRow,
     826          65 :                                     STR_PIVOT_STYLE_RESULT );
     827         105 :         }
     828             :     }
     829         700 : }
     830             : 
     831         149 : void ScDPOutput::FieldCell(
     832             :     SCCOL nCol, SCROW nRow, SCTAB nTab, const ScDPOutLevelData& rData, bool bInTable)
     833             : {
     834             :     // Avoid unwanted automatic format detection.
     835         149 :     ScSetStringParam aParam;
     836         149 :     aParam.mbDetectNumberFormat = false;
     837         149 :     aParam.meSetTextNumFormat = ScSetStringParam::Always;
     838         149 :     aParam.mbHandleApostrophe = false;
     839         149 :     pDoc->SetString(nCol, nRow, nTab, rData.maCaption, &aParam);
     840             : 
     841         149 :     if (bInTable)
     842         127 :         lcl_SetFrame( pDoc,nTab, nCol,nRow, nCol,nRow, 20 );
     843             : 
     844             :     // For field button drawing
     845         149 :     sal_uInt16 nMergeFlag = 0;
     846         149 :     if (rData.mbHasHiddenMember)
     847           4 :         nMergeFlag |= SC_MF_HIDDEN_MEMBER;
     848             : 
     849         149 :     if (rData.mbPageDim)
     850             :     {
     851          22 :         nMergeFlag |= SC_MF_BUTTON_POPUP;
     852          22 :         pDoc->ApplyFlagsTab(nCol, nRow, nCol, nRow, nTab, SC_MF_BUTTON);
     853          22 :         pDoc->ApplyFlagsTab(nCol+1, nRow, nCol+1, nRow, nTab, nMergeFlag);
     854             :     }
     855             :     else
     856             :     {
     857         127 :         nMergeFlag |= SC_MF_BUTTON;
     858         127 :         if (!rData.mbDataLayout)
     859         120 :             nMergeFlag |= SC_MF_BUTTON_POPUP;
     860         127 :         pDoc->ApplyFlagsTab(nCol, nRow, nCol, nRow, nTab, nMergeFlag);
     861             :     }
     862             : 
     863             : 
     864         149 :     lcl_SetStyleById( pDoc,nTab, nCol,nRow, nCol,nRow, STR_PIVOT_STYLE_FIELDNAME );
     865         149 : }
     866             : 
     867          50 : static void lcl_DoFilterButton( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab )
     868             : {
     869          50 :     pDoc->SetString( nCol, nRow, nTab, ScGlobal::GetRscString(STR_CELL_FILTER) );
     870          50 :     pDoc->ApplyFlagsTab(nCol, nRow, nCol, nRow, nTab, SC_MF_BUTTON);
     871          50 : }
     872             : 
     873        1214 : void ScDPOutput::CalcSizes()
     874             : {
     875        1214 :     if (!bSizesValid)
     876             :     {
     877             :         //  get column size of data from first row
     878             :         //! allow different sizes (and clear following areas) ???
     879             : 
     880         178 :         nRowCount = aData.getLength();
     881         178 :         const uno::Sequence<sheet::DataResult>* pRowAry = aData.getConstArray();
     882         178 :         nColCount = nRowCount ? ( pRowAry[0].getLength() ) : 0;
     883             : 
     884         178 :         nHeaderSize = 1;
     885         178 :         if (GetHeaderLayout() && nColFieldCount == 0)
     886             :             // Insert an extra header row only when there is no column field.
     887           0 :             nHeaderSize = 2;
     888             : 
     889             :         //  calculate output positions and sizes
     890             : 
     891         178 :         long nPageSize = 0;     //! use page fields!
     892         178 :         if ( bDoFilter || nPageFieldCount )
     893             :         {
     894         118 :             nPageSize += nPageFieldCount + 1;   // plus one empty row
     895         118 :             if ( bDoFilter )
     896         116 :                 ++nPageSize;        //  filter button above the page fields
     897             :         }
     898             : 
     899         356 :         if ( aStartPos.Col() + nRowFieldCount + nColCount - 1 > MAXCOL ||
     900         178 :              aStartPos.Row() + nPageSize + nHeaderSize + nColFieldCount + nRowCount > MAXROW )
     901             :         {
     902           0 :             bSizeOverflow = true;
     903             :         }
     904             : 
     905         178 :         nTabStartCol = aStartPos.Col();
     906         178 :         nTabStartRow = aStartPos.Row() + (SCROW)nPageSize;          // below page fields
     907         178 :         nMemberStartCol = nTabStartCol;
     908         178 :         nMemberStartRow = nTabStartRow + (SCROW) nHeaderSize;
     909         178 :         nDataStartCol = nMemberStartCol + (SCCOL)nRowFieldCount;
     910         178 :         nDataStartRow = nMemberStartRow + (SCROW)nColFieldCount;
     911         178 :         if ( nColCount > 0 )
     912         176 :             nTabEndCol = nDataStartCol + (SCCOL)nColCount - 1;
     913             :         else
     914           2 :             nTabEndCol = nDataStartCol;     // single column will remain empty
     915             :         // if page fields are involved, include the page selection cells
     916         178 :         if ( nPageFieldCount > 0 && nTabEndCol < nTabStartCol + 1 )
     917           2 :             nTabEndCol = nTabStartCol + 1;
     918         178 :         if ( nRowCount > 0 )
     919         176 :             nTabEndRow = nDataStartRow + (SCROW)nRowCount - 1;
     920             :         else
     921           2 :             nTabEndRow = nDataStartRow;     // single row will remain empty
     922         178 :         bSizesValid = true;
     923             :     }
     924        1214 : }
     925             : 
     926         266 : sal_Int32 ScDPOutput::GetPositionType(const ScAddress& rPos)
     927             : {
     928             :     using namespace ::com::sun::star::sheet;
     929             : 
     930         266 :     SCCOL nCol = rPos.Col();
     931         266 :     SCROW nRow = rPos.Row();
     932         266 :     SCTAB nTab = rPos.Tab();
     933         266 :     if ( nTab != aStartPos.Tab() )
     934           0 :         return DataPilotTablePositionType::NOT_IN_TABLE;
     935             : 
     936         266 :     CalcSizes();
     937             : 
     938             :     // Make sure the cursor is within the table.
     939         266 :     if (nCol < nTabStartCol || nRow < nTabStartRow || nCol > nTabEndCol || nRow > nTabEndRow)
     940           0 :         return DataPilotTablePositionType::NOT_IN_TABLE;
     941             : 
     942             :     // test for result data area.
     943         266 :     if (nCol >= nDataStartCol && nCol <= nTabEndCol && nRow >= nDataStartRow && nRow <= nTabEndRow)
     944         194 :         return DataPilotTablePositionType::RESULT;
     945             : 
     946          72 :     bool bInColHeader = (nRow >= nTabStartRow && nRow < nDataStartRow);
     947          72 :     bool bInRowHeader = (nCol >= nTabStartCol && nCol < nDataStartCol);
     948             : 
     949          72 :     if (bInColHeader && bInRowHeader)
     950             :         // probably in that ugly little box at the upper-left corner of the table.
     951          12 :         return DataPilotTablePositionType::OTHER;
     952             : 
     953          60 :     if (bInColHeader)
     954             :     {
     955          36 :         if (nRow == nTabStartRow)
     956             :             // first row in the column header area is always used for column
     957             :             // field buttons.
     958          12 :             return DataPilotTablePositionType::OTHER;
     959             : 
     960          24 :         return DataPilotTablePositionType::COLUMN_HEADER;
     961             :     }
     962             : 
     963          24 :     if (bInRowHeader)
     964          24 :         return DataPilotTablePositionType::ROW_HEADER;
     965             : 
     966           0 :     return DataPilotTablePositionType::OTHER;
     967             : }
     968             : 
     969          82 : void ScDPOutput::Output()
     970             : {
     971             :     long nField;
     972          82 :     SCTAB nTab = aStartPos.Tab();
     973          82 :     const uno::Sequence<sheet::DataResult>* pRowAry = aData.getConstArray();
     974             : 
     975             :     //  calculate output positions and sizes
     976             : 
     977          82 :     CalcSizes();
     978          82 :     if ( bSizeOverflow || bResultsError )   // does output area exceed sheet limits?
     979          82 :         return;                             // nothing
     980             : 
     981             :     //  clear whole (new) output area
     982             :     //! when modifying table, clear old area
     983             :     //! include IDF_OBJECTS ???
     984          82 :     pDoc->DeleteAreaTab( aStartPos.Col(), aStartPos.Row(), nTabEndCol, nTabEndRow, nTab, IDF_ALL );
     985             : 
     986          82 :     if ( bDoFilter )
     987          50 :         lcl_DoFilterButton( pDoc, aStartPos.Col(), aStartPos.Row(), nTab );
     988             : 
     989             :     //  output page fields:
     990             : 
     991         104 :     for (nField=0; nField<nPageFieldCount; nField++)
     992             :     {
     993          22 :         SCCOL nHdrCol = aStartPos.Col();
     994          22 :         SCROW nHdrRow = aStartPos.Row() + nField + ( bDoFilter ? 1 : 0 );
     995             :         // draw without frame for consistency with filter button:
     996          22 :         FieldCell(nHdrCol, nHdrRow, nTab, pPageFields[nField], false);
     997          22 :         SCCOL nFldCol = nHdrCol + 1;
     998             : 
     999          22 :         OUString aPageValue = ScResId(SCSTR_ALL).toString();
    1000          22 :         const uno::Sequence<sheet::MemberResult>& rRes = pPageFields[nField].aResult;
    1001          22 :         sal_Int32 n = rRes.getLength();
    1002          22 :         if (n == 1)
    1003           3 :             aPageValue = rRes[0].Caption;
    1004          19 :         else if (n > 1)
    1005           0 :             aPageValue = ScResId(SCSTR_MULTIPLE).toString();
    1006             : 
    1007          22 :         ScSetStringParam aParam;
    1008          22 :         aParam.setTextInput();
    1009          22 :         pDoc->SetString(nFldCol, nHdrRow, nTab, aPageValue, &aParam);
    1010             : 
    1011          22 :         lcl_SetFrame( pDoc,nTab, nFldCol,nHdrRow, nFldCol,nHdrRow, 20 );
    1012          22 :     }
    1013             : 
    1014             :     //  data description
    1015             :     //  (may get overwritten by first row field)
    1016             : 
    1017          82 :     if (aDataDescription.isEmpty())
    1018             :     {
    1019             :         //! use default string ("result") ?
    1020             :     }
    1021          82 :     pDoc->SetString(nTabStartCol, nTabStartRow, nTab, aDataDescription);
    1022             : 
    1023             :     //  set STR_PIVOT_STYLE_INNER for whole data area (subtotals are overwritten)
    1024             : 
    1025          82 :     if ( nDataStartRow > nTabStartRow )
    1026             :         lcl_SetStyleById( pDoc, nTab, nTabStartCol, nTabStartRow, nTabEndCol, nDataStartRow-1,
    1027          82 :                             STR_PIVOT_STYLE_TOP );
    1028             :     lcl_SetStyleById( pDoc, nTab, nDataStartCol, nDataStartRow, nTabEndCol, nTabEndRow,
    1029          82 :                         STR_PIVOT_STYLE_INNER );
    1030             : 
    1031             :     //  output column headers:
    1032             :     ScDPOutputImpl outputimp( pDoc, nTab,
    1033             :         nTabStartCol, nTabStartRow,
    1034          82 :         nDataStartCol, nDataStartRow, nTabEndCol, nTabEndRow );
    1035         127 :     for (nField=0; nField<nColFieldCount; nField++)
    1036             :     {
    1037          45 :         SCCOL nHdrCol = nDataStartCol + (SCCOL)nField;              //! check for overflow
    1038          45 :         FieldCell(nHdrCol, nTabStartRow, nTab, pColFields[nField], true);
    1039             : 
    1040          45 :         SCROW nRowPos = nMemberStartRow + (SCROW)nField;                //! check for overflow
    1041          45 :         const uno::Sequence<sheet::MemberResult> rSequence = pColFields[nField].aResult;
    1042          45 :         const sheet::MemberResult* pArray = rSequence.getConstArray();
    1043          45 :         long nThisColCount = rSequence.getLength();
    1044             :         OSL_ENSURE( nThisColCount == nColCount, "count mismatch" );     //! ???
    1045         294 :         for (long nCol=0; nCol<nThisColCount; nCol++)
    1046             :         {
    1047         249 :             SCCOL nColPos = nDataStartCol + (SCCOL)nCol;                //! check for overflow
    1048         249 :             HeaderCell( nColPos, nRowPos, nTab, pArray[nCol], true, nField );
    1049         490 :             if ( ( pArray[nCol].Flags & sheet::MemberResultFlags::HASMEMBER ) &&
    1050         241 :                 !( pArray[nCol].Flags & sheet::MemberResultFlags::SUBTOTAL ) )
    1051             :             {
    1052         201 :                 long nEnd = nCol;
    1053         406 :                 while ( nEnd+1 < nThisColCount && ( pArray[nEnd+1].Flags & sheet::MemberResultFlags::CONTINUE ) )
    1054           4 :                     ++nEnd;
    1055         201 :                 SCCOL nEndColPos = nDataStartCol + (SCCOL)nEnd;     //! check for overflow
    1056         201 :                 if ( nField+1 < nColFieldCount )
    1057             :                 {
    1058          16 :                     if ( nField == nColFieldCount - 2 )
    1059             :                     {
    1060          16 :                         outputimp.AddCol( nColPos );
    1061          16 :                         if ( nColPos + 1 == nEndColPos  )
    1062           0 :                             outputimp.OutputBlockFrame( nColPos,nRowPos, nEndColPos,nRowPos+1, true );
    1063             :                     }
    1064             :                     else
    1065           0 :                         outputimp.OutputBlockFrame( nColPos,nRowPos, nEndColPos,nRowPos );
    1066             : 
    1067          16 :                     lcl_SetStyleById( pDoc, nTab, nColPos,nRowPos, nEndColPos,nDataStartRow-1, STR_PIVOT_STYLE_CATEGORY );
    1068             :                 }
    1069             :                 else
    1070         185 :                     lcl_SetStyleById( pDoc, nTab, nColPos,nRowPos, nColPos,nDataStartRow-1, STR_PIVOT_STYLE_CATEGORY );
    1071             :             }
    1072          48 :             else if (  pArray[nCol].Flags & sheet::MemberResultFlags::SUBTOTAL )
    1073          40 :                 outputimp.AddCol( nColPos );
    1074             : 
    1075             :             // Apply the same number format as in data source.
    1076         249 :             pDoc->ApplyAttr(nColPos, nRowPos, nTab, SfxUInt32Item(ATTR_VALUE_FORMAT, pColFields[nField].mnSrcNumFmt));
    1077             :         }
    1078          45 :         if ( nField== 0 && nColFieldCount == 1 )
    1079          37 :             outputimp.OutputBlockFrame( nDataStartCol,nTabStartRow, nTabEndCol,nRowPos-1 );
    1080          45 :     }
    1081             : 
    1082             :     //  output row headers:
    1083         164 :     std::vector<bool> vbSetBorder;
    1084          82 :     vbSetBorder.resize( nTabEndRow - nDataStartRow + 1, false );
    1085         164 :     for (nField=0; nField<nRowFieldCount; nField++)
    1086             :     {
    1087          82 :         SCCOL nHdrCol = nTabStartCol + (SCCOL)nField;                   //! check for overflow
    1088          82 :         SCROW nHdrRow = nDataStartRow - 1;
    1089          82 :         FieldCell(nHdrCol, nHdrRow, nTab, pRowFields[nField], true);
    1090             : 
    1091          82 :         SCCOL nColPos = nMemberStartCol + (SCCOL)nField;                //! check for overflow
    1092          82 :         const uno::Sequence<sheet::MemberResult> rSequence = pRowFields[nField].aResult;
    1093          82 :         const sheet::MemberResult* pArray = rSequence.getConstArray();
    1094          82 :         long nThisRowCount = rSequence.getLength();
    1095             :         OSL_ENSURE( nThisRowCount == nRowCount, "count mismatch" );     //! ???
    1096         533 :         for (long nRow=0; nRow<nThisRowCount; nRow++)
    1097             :         {
    1098         451 :             SCROW nRowPos = nDataStartRow + (SCROW)nRow;                //! check for overflow
    1099         451 :             HeaderCell( nColPos, nRowPos, nTab, pArray[nRow], false, nField );
    1100         859 :             if ( ( pArray[nRow].Flags & sheet::MemberResultFlags::HASMEMBER ) &&
    1101         408 :                 !( pArray[nRow].Flags & sheet::MemberResultFlags::SUBTOTAL ) )
    1102             :             {
    1103         343 :                 if ( nField+1 < nRowFieldCount )
    1104             :                 {
    1105          47 :                     long nEnd = nRow;
    1106         120 :                     while ( nEnd+1 < nThisRowCount && ( pArray[nEnd+1].Flags & sheet::MemberResultFlags::CONTINUE ) )
    1107          26 :                         ++nEnd;
    1108          47 :                     SCROW nEndRowPos = nDataStartRow + (SCROW)nEnd;     //! check for overflow
    1109          47 :                     outputimp.AddRow( nRowPos );
    1110          47 :                     if ( vbSetBorder[ nRow ] == false )
    1111             :                     {
    1112          44 :                         outputimp.OutputBlockFrame( nColPos, nRowPos, nTabEndCol, nEndRowPos );
    1113          44 :                         vbSetBorder[ nRow ]  = true;
    1114             :                     }
    1115          47 :                     outputimp.OutputBlockFrame( nColPos, nRowPos, nColPos, nEndRowPos );
    1116             : 
    1117          47 :                     if ( nField == nRowFieldCount - 2 )
    1118          44 :                         outputimp.OutputBlockFrame( nColPos+1, nRowPos, nColPos+1, nEndRowPos );
    1119             : 
    1120          47 :                     lcl_SetStyleById( pDoc, nTab, nColPos,nRowPos, nDataStartCol-1,nEndRowPos, STR_PIVOT_STYLE_CATEGORY );
    1121             :                 }
    1122             :                 else
    1123         296 :                     lcl_SetStyleById( pDoc, nTab, nColPos,nRowPos, nDataStartCol-1,nRowPos, STR_PIVOT_STYLE_CATEGORY );
    1124             :             }
    1125         108 :             else if (  pArray[nRow].Flags & sheet::MemberResultFlags::SUBTOTAL )
    1126          65 :                 outputimp.AddRow( nRowPos );
    1127             : 
    1128             :             // Apply the same number format as in data source.
    1129         451 :             pDoc->ApplyAttr(nColPos, nRowPos, nTab, SfxUInt32Item(ATTR_VALUE_FORMAT, pRowFields[nField].mnSrcNumFmt));
    1130             :         }
    1131          82 :     }
    1132             : 
    1133             :     //  output data results:
    1134             : 
    1135         457 :     for (long nRow=0; nRow<nRowCount; nRow++)
    1136             :     {
    1137         375 :         SCROW nRowPos = nDataStartRow + (SCROW)nRow;                    //! check for overflow
    1138         375 :         const sheet::DataResult* pColAry = pRowAry[nRow].getConstArray();
    1139         375 :         long nThisColCount = pRowAry[nRow].getLength();
    1140             :         OSL_ENSURE( nThisColCount == nColCount, "count mismatch" );     //! ???
    1141        1754 :         for (long nCol=0; nCol<nThisColCount; nCol++)
    1142             :         {
    1143        1379 :             SCCOL nColPos = nDataStartCol + (SCCOL)nCol;                //! check for overflow
    1144        1379 :             DataCell( nColPos, nRowPos, nTab, pColAry[nCol] );
    1145             :         }
    1146             :     }
    1147             : 
    1148         164 :     outputimp.OutputDataArea();
    1149             : }
    1150             : 
    1151         177 : ScRange ScDPOutput::GetOutputRange( sal_Int32 nRegionType )
    1152             : {
    1153             :     using namespace ::com::sun::star::sheet;
    1154             : 
    1155         177 :     CalcSizes();
    1156             : 
    1157         177 :     SCTAB nTab = aStartPos.Tab();
    1158         177 :     switch (nRegionType)
    1159             :     {
    1160             :         case DataPilotOutputRangeType::RESULT:
    1161           5 :             return ScRange(nDataStartCol, nDataStartRow, nTab, nTabEndCol, nTabEndRow, nTab);
    1162             :         case DataPilotOutputRangeType::TABLE:
    1163           5 :             return ScRange(aStartPos.Col(), nTabStartRow, nTab, nTabEndCol, nTabEndRow, nTab);
    1164             :         default:
    1165             :             OSL_ENSURE(nRegionType == DataPilotOutputRangeType::WHOLE, "ScDPOutput::GetOutputRange: unknown region type");
    1166         167 :         break;
    1167             :     }
    1168         167 :     return ScRange(aStartPos.Col(), aStartPos.Row(), nTab, nTabEndCol, nTabEndRow, nTab);
    1169             : }
    1170             : 
    1171          95 : bool ScDPOutput::HasError()
    1172             : {
    1173          95 :     CalcSizes();
    1174             : 
    1175          95 :     return bSizeOverflow || bResultsError;
    1176             : }
    1177             : 
    1178          83 : long ScDPOutput::GetHeaderRows()
    1179             : {
    1180          83 :     return nPageFieldCount + ( bDoFilter ? 1 : 0 );
    1181             : }
    1182             : 
    1183           0 : void ScDPOutput::GetMemberResultNames(ScDPUniqueStringSet& rNames, long nDimension)
    1184             : {
    1185             :     //  Return the list of all member names in a dimension's MemberResults.
    1186             :     //  Only the dimension has to be compared because this is only used with table data,
    1187             :     //  where each dimension occurs only once.
    1188             : 
    1189           0 :     uno::Sequence<sheet::MemberResult> aMemberResults;
    1190           0 :     bool bFound = false;
    1191             :     long nField;
    1192             : 
    1193             :     // look in column fields
    1194             : 
    1195           0 :     for (nField=0; nField<nColFieldCount && !bFound; nField++)
    1196           0 :         if ( pColFields[nField].nDim == nDimension )
    1197             :         {
    1198           0 :             aMemberResults = pColFields[nField].aResult;
    1199           0 :             bFound = true;
    1200             :         }
    1201             : 
    1202             :     // look in row fields
    1203             : 
    1204           0 :     for (nField=0; nField<nRowFieldCount && !bFound; nField++)
    1205           0 :         if ( pRowFields[nField].nDim == nDimension )
    1206             :         {
    1207           0 :             aMemberResults = pRowFields[nField].aResult;
    1208           0 :             bFound = true;
    1209             :         }
    1210             : 
    1211             :     // collect the member names
    1212             : 
    1213           0 :     if ( bFound )
    1214             :     {
    1215           0 :         const sheet::MemberResult* pArray = aMemberResults.getConstArray();
    1216           0 :         long nResultCount = aMemberResults.getLength();
    1217             : 
    1218           0 :         for (long nItem=0; nItem<nResultCount; nItem++)
    1219             :         {
    1220           0 :             if ( pArray[nItem].Flags & sheet::MemberResultFlags::HASMEMBER )
    1221           0 :                 rNames.insert(pArray[nItem].Name);
    1222             :         }
    1223           0 :     }
    1224           0 : }
    1225             : 
    1226          83 : void ScDPOutput::SetHeaderLayout(bool bUseGrid)
    1227             : {
    1228          83 :     mbHeaderLayout = bUseGrid;
    1229          83 :     bSizesValid = false;
    1230          83 : }
    1231             : 
    1232         178 : bool ScDPOutput::GetHeaderLayout() const
    1233             : {
    1234         178 :     return mbHeaderLayout;
    1235             : }
    1236             : 
    1237             : namespace {
    1238             : 
    1239         327 : void lcl_GetTableVars( sal_Int32& rGrandTotalCols, sal_Int32& rGrandTotalRows, sal_Int32& rDataLayoutIndex,
    1240             :                        std::vector<OUString>& rDataNames, std::vector<OUString>& rGivenNames,
    1241             :                        sheet::DataPilotFieldOrientation& rDataOrient,
    1242             :                        const uno::Reference<sheet::XDimensionsSupplier>& xSource )
    1243             : {
    1244         327 :     rDataLayoutIndex = -1;  // invalid
    1245         327 :     rGrandTotalCols = 0;
    1246         327 :     rGrandTotalRows = 0;
    1247         327 :     rDataOrient = sheet::DataPilotFieldOrientation_HIDDEN;
    1248             : 
    1249         327 :     uno::Reference<beans::XPropertySet> xSrcProp( xSource, uno::UNO_QUERY );
    1250             :     bool bColGrand = ScUnoHelpFunctions::GetBoolProperty(
    1251         327 :         xSrcProp, OUString(SC_UNO_DP_COLGRAND));
    1252         327 :     if ( bColGrand )
    1253         327 :         rGrandTotalCols = 1;    // default if data layout not in columns
    1254             : 
    1255             :     bool bRowGrand = ScUnoHelpFunctions::GetBoolProperty(
    1256         327 :         xSrcProp, OUString(SC_UNO_DP_ROWGRAND));
    1257         327 :     if ( bRowGrand )
    1258         327 :         rGrandTotalRows = 1;    // default if data layout not in rows
    1259             : 
    1260         327 :     if ( xSource.is() )
    1261             :     {
    1262             :         // find index and orientation of "data layout" dimension, count data dimensions
    1263             : 
    1264         327 :         sal_Int32 nDataCount = 0;
    1265             : 
    1266         327 :         uno::Reference<container::XIndexAccess> xDims = new ScNameToIndexAccess( xSource->getDimensions() );
    1267         327 :         long nDimCount = xDims->getCount();
    1268        2289 :         for (long nDim=0; nDim<nDimCount; nDim++)
    1269             :         {
    1270             :             uno::Reference<uno::XInterface> xDim =
    1271        1962 :                     ScUnoHelpFunctions::AnyToInterface( xDims->getByIndex(nDim) );
    1272        3924 :             uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
    1273        1962 :             if ( xDimProp.is() )
    1274             :             {
    1275             :                 sheet::DataPilotFieldOrientation eDimOrient =
    1276             :                     (sheet::DataPilotFieldOrientation) ScUnoHelpFunctions::GetEnumProperty(
    1277             :                         xDimProp, OUString(SC_UNO_DP_ORIENTATION),
    1278        1962 :                         sheet::DataPilotFieldOrientation_HIDDEN );
    1279        3924 :                 if ( ScUnoHelpFunctions::GetBoolProperty( xDimProp,
    1280        3924 :                                          OUString(SC_UNO_DP_ISDATALAYOUT) ) )
    1281             :                 {
    1282         327 :                     rDataLayoutIndex = nDim;
    1283         327 :                     rDataOrient = eDimOrient;
    1284             :                 }
    1285        1962 :                 if ( eDimOrient == sheet::DataPilotFieldOrientation_DATA )
    1286             :                 {
    1287         327 :                     OUString aSourceName;
    1288         654 :                     OUString aGivenName;
    1289         327 :                     ScDPOutput::GetDataDimensionNames( aSourceName, aGivenName, xDim );
    1290             :                     try
    1291             :                     {
    1292         327 :                         uno::Any aValue = xDimProp->getPropertyValue( SC_UNO_DP_LAYOUTNAME );
    1293             : 
    1294         327 :                         if( aValue.hasValue() )
    1295             :                         {
    1296         327 :                             OUString strLayoutName;
    1297             : 
    1298         327 :                             if( ( aValue >>= strLayoutName ) && !strLayoutName.isEmpty() )
    1299           0 :                                 aGivenName = strLayoutName;
    1300         327 :                         }
    1301             :                     }
    1302           0 :                     catch(const uno::Exception&)
    1303             :                     {
    1304             :                     }
    1305         327 :                     rDataNames.push_back( aSourceName );
    1306         327 :                     rGivenNames.push_back( aGivenName );
    1307             : 
    1308         654 :                     ++nDataCount;
    1309             :                 }
    1310             :             }
    1311        1962 :         }
    1312             : 
    1313         327 :         if ( ( rDataOrient == sheet::DataPilotFieldOrientation_COLUMN ) && bColGrand )
    1314           0 :             rGrandTotalCols = nDataCount;
    1315         327 :         else if ( ( rDataOrient == sheet::DataPilotFieldOrientation_ROW ) && bRowGrand )
    1316           0 :             rGrandTotalRows = nDataCount;
    1317         327 :     }
    1318         327 : }
    1319             : 
    1320             : }
    1321             : 
    1322         266 : void ScDPOutput::GetPositionData(const ScAddress& rPos, DataPilotTablePositionData& rPosData)
    1323             : {
    1324             :     using namespace ::com::sun::star::sheet;
    1325             : 
    1326         266 :     SCCOL nCol = rPos.Col();
    1327         266 :     SCROW nRow = rPos.Row();
    1328         266 :     SCTAB nTab = rPos.Tab();
    1329         266 :     if ( nTab != aStartPos.Tab() )
    1330           0 :         return;                                     // wrong sheet
    1331             : 
    1332             :     //  calculate output positions and sizes
    1333             : 
    1334         266 :     CalcSizes();
    1335             : 
    1336         266 :     rPosData.PositionType = GetPositionType(rPos);
    1337         266 :     switch (rPosData.PositionType)
    1338             :     {
    1339             :         case DataPilotTablePositionType::RESULT:
    1340             :         {
    1341         194 :             vector<DataPilotFieldFilter> aFilters;
    1342         194 :             GetDataResultPositionData(aFilters, rPos);
    1343         194 :             sal_Int32 nSize = aFilters.size();
    1344             : 
    1345         388 :             DataPilotTableResultData aResData;
    1346         194 :             aResData.FieldFilters.realloc(nSize);
    1347         874 :             for (sal_Int32 i = 0; i < nSize; ++i)
    1348         680 :                 aResData.FieldFilters[i] = aFilters[i];
    1349             : 
    1350         194 :             aResData.DataFieldIndex = 0;
    1351         388 :             Reference<beans::XPropertySet> xPropSet(xSource, UNO_QUERY);
    1352         194 :             if (xPropSet.is())
    1353             :             {
    1354             :                 sal_Int32 nDataFieldCount = ScUnoHelpFunctions::GetLongProperty( xPropSet,
    1355         194 :                                             OUString(SC_UNO_DP_DATAFIELDCOUNT) );
    1356         194 :                 if (nDataFieldCount > 0)
    1357         194 :                     aResData.DataFieldIndex = (nRow - nDataStartRow) % nDataFieldCount;
    1358             :             }
    1359             : 
    1360             :             // Copy appropriate DataResult object from the cached sheet::DataResult table.
    1361         388 :             if (aData.getLength() > nRow - nDataStartRow &&
    1362         194 :                 aData[nRow-nDataStartRow].getLength() > nCol-nDataStartCol)
    1363         194 :                 aResData.Result = aData[nRow-nDataStartRow][nCol-nDataStartCol];
    1364             : 
    1365         194 :             rPosData.PositionData = makeAny(aResData);
    1366         388 :             return;
    1367             :         }
    1368             :         case DataPilotTablePositionType::COLUMN_HEADER:
    1369             :         {
    1370          24 :             long nField = nRow - nTabStartRow - 1; // 1st line is used for the buttons
    1371          24 :             if (nField < 0)
    1372           0 :                 break;
    1373             : 
    1374          24 :             const uno::Sequence<sheet::MemberResult> rSequence = pColFields[nField].aResult;
    1375          24 :             if (rSequence.getLength() == 0)
    1376           0 :                 break;
    1377          24 :             const sheet::MemberResult* pArray = rSequence.getConstArray();
    1378             : 
    1379          24 :             long nItem = nCol - nDataStartCol;
    1380             :             //  get origin of "continue" fields
    1381          48 :             while (nItem > 0 && ( pArray[nItem].Flags & sheet::MemberResultFlags::CONTINUE) )
    1382           0 :                 --nItem;
    1383             : 
    1384          24 :             if (nItem < 0)
    1385           0 :                 break;
    1386             : 
    1387          48 :             DataPilotTableHeaderData aHeaderData;
    1388          24 :             aHeaderData.MemberName = OUString(pArray[nItem].Name);
    1389          24 :             aHeaderData.Flags = pArray[nItem].Flags;
    1390          24 :             aHeaderData.Dimension = static_cast<sal_Int32>(pColFields[nField].nDim);
    1391          24 :             aHeaderData.Hierarchy = static_cast<sal_Int32>(pColFields[nField].nHier);
    1392          24 :             aHeaderData.Level     = static_cast<sal_Int32>(pColFields[nField].nLevel);
    1393             : 
    1394          24 :             rPosData.PositionData = makeAny(aHeaderData);
    1395          24 :             return;
    1396             :         }
    1397             :         case DataPilotTablePositionType::ROW_HEADER:
    1398             :         {
    1399          24 :             long nField = nCol - nTabStartCol;
    1400          24 :             if (nField < 0)
    1401           0 :                 break;
    1402             : 
    1403          24 :             const uno::Sequence<sheet::MemberResult> rSequence = pRowFields[nField].aResult;
    1404          24 :             if (rSequence.getLength() == 0)
    1405           0 :                 break;
    1406          24 :             const sheet::MemberResult* pArray = rSequence.getConstArray();
    1407             : 
    1408          24 :             long nItem = nRow - nDataStartRow;
    1409             :             //  get origin of "continue" fields
    1410          48 :             while ( nItem > 0 && (pArray[nItem].Flags & sheet::MemberResultFlags::CONTINUE) )
    1411           0 :                 --nItem;
    1412             : 
    1413          24 :             if (nItem < 0)
    1414           0 :                 break;
    1415             : 
    1416          48 :             DataPilotTableHeaderData aHeaderData;
    1417          24 :             aHeaderData.MemberName = OUString(pArray[nItem].Name);
    1418          24 :             aHeaderData.Flags = pArray[nItem].Flags;
    1419          24 :             aHeaderData.Dimension = static_cast<sal_Int32>(pRowFields[nField].nDim);
    1420          24 :             aHeaderData.Hierarchy = static_cast<sal_Int32>(pRowFields[nField].nHier);
    1421          24 :             aHeaderData.Level     = static_cast<sal_Int32>(pRowFields[nField].nLevel);
    1422             : 
    1423          24 :             rPosData.PositionData = makeAny(aHeaderData);
    1424          24 :             return;
    1425             :         }
    1426             :     }
    1427             : }
    1428             : 
    1429         327 : bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>& rFilters, const ScAddress& rPos)
    1430             : {
    1431             :     // Check to make sure there is at least one data field.
    1432         327 :     Reference<beans::XPropertySet> xPropSet(xSource, UNO_QUERY);
    1433         327 :     if (!xPropSet.is())
    1434           0 :         return false;
    1435             : 
    1436             :     sal_Int32 nDataFieldCount = ScUnoHelpFunctions::GetLongProperty( xPropSet,
    1437         327 :                                 OUString(SC_UNO_DP_DATAFIELDCOUNT) );
    1438         327 :     if (nDataFieldCount == 0)
    1439             :         // No data field is present in this datapilot table.
    1440           0 :         return false;
    1441             : 
    1442             :     // #i111421# use lcl_GetTableVars for correct size of totals and data layout position
    1443             :     sal_Int32 nGrandTotalCols;
    1444             :     sal_Int32 nGrandTotalRows;
    1445             :     sal_Int32 nDataLayoutIndex;
    1446         654 :     std::vector<OUString> aDataNames;
    1447         654 :     std::vector<OUString> aGivenNames;
    1448             :     sheet::DataPilotFieldOrientation eDataOrient;
    1449         327 :     lcl_GetTableVars( nGrandTotalCols, nGrandTotalRows, nDataLayoutIndex, aDataNames, aGivenNames, eDataOrient, xSource );
    1450             : 
    1451         327 :     SCCOL nCol = rPos.Col();
    1452         327 :     SCROW nRow = rPos.Row();
    1453         327 :     SCTAB nTab = rPos.Tab();
    1454         327 :     if ( nTab != aStartPos.Tab() )
    1455           0 :         return false;                                     // wrong sheet
    1456             : 
    1457         327 :     CalcSizes();
    1458             : 
    1459             :     // test for data area.
    1460         327 :     if (nCol < nDataStartCol || nCol > nTabEndCol || nRow < nDataStartRow || nRow > nTabEndRow)
    1461             :     {
    1462             :         // Cell is outside the data field area.
    1463           0 :         return false;
    1464             :     }
    1465             : 
    1466         327 :     bool bFilterByCol = (nCol <= static_cast<SCCOL>(nTabEndCol - nGrandTotalCols));
    1467         327 :     bool bFilterByRow = (nRow <= static_cast<SCROW>(nTabEndRow - nGrandTotalRows));
    1468             : 
    1469             :     // column fields
    1470         897 :     for (SCCOL nColField = 0; nColField < nColFieldCount && bFilterByCol; ++nColField)
    1471             :     {
    1472         570 :         if (pColFields[nColField].nDim == nDataLayoutIndex)
    1473             :             // There is no sense including the data layout field for filtering.
    1474           0 :             continue;
    1475             : 
    1476         570 :         sheet::DataPilotFieldFilter filter;
    1477         570 :         filter.FieldName = pColFields[nColField].maName;
    1478             : 
    1479        1140 :         const uno::Sequence<sheet::MemberResult> rSequence = pColFields[nColField].aResult;
    1480         570 :         const sheet::MemberResult* pArray = rSequence.getConstArray();
    1481             : 
    1482             :         OSL_ENSURE(nDataStartCol + rSequence.getLength() - 1 == nTabEndCol, "ScDPOutput::GetDataFieldCellData: error in geometric assumption");
    1483             : 
    1484         570 :         long nItem = nCol - nDataStartCol;
    1485             :                 //  get origin of "continue" fields
    1486        1140 :         while ( nItem > 0 && (pArray[nItem].Flags & sheet::MemberResultFlags::CONTINUE) )
    1487           0 :             --nItem;
    1488             : 
    1489         570 :         filter.MatchValue = pArray[nItem].Name;
    1490         570 :         rFilters.push_back(filter);
    1491         570 :     }
    1492             : 
    1493             :     // row fields
    1494         897 :     for (SCROW nRowField = 0; nRowField < nRowFieldCount && bFilterByRow; ++nRowField)
    1495             :     {
    1496         570 :         if (pRowFields[nRowField].nDim == nDataLayoutIndex)
    1497             :             // There is no sense including the data layout field for filtering.
    1498           0 :             continue;
    1499             : 
    1500         570 :         sheet::DataPilotFieldFilter filter;
    1501         570 :         filter.FieldName = pRowFields[nRowField].maName;
    1502             : 
    1503        1140 :         const uno::Sequence<sheet::MemberResult> rSequence = pRowFields[nRowField].aResult;
    1504         570 :         const sheet::MemberResult* pArray = rSequence.getConstArray();
    1505             : 
    1506             :         OSL_ENSURE(nDataStartRow + rSequence.getLength() - 1 == nTabEndRow, "ScDPOutput::GetDataFieldCellData: error in geometric assumption");
    1507             : 
    1508         570 :         long nItem = nRow - nDataStartRow;
    1509             :             //  get origin of "continue" fields
    1510        1140 :         while ( nItem > 0 && (pArray[nItem].Flags & sheet::MemberResultFlags::CONTINUE) )
    1511           0 :             --nItem;
    1512             : 
    1513         570 :         filter.MatchValue = pArray[nItem].Name;
    1514         570 :         rFilters.push_back(filter);
    1515         570 :     }
    1516             : 
    1517         654 :     return true;
    1518             : }
    1519             : 
    1520             : namespace {
    1521             : 
    1522         339 : OUString lcl_GetDataFieldName( const OUString& rSourceName, sheet::GeneralFunction eFunc )
    1523             : {
    1524         339 :     sal_uInt16 nStrId = 0;
    1525         339 :     switch ( eFunc )
    1526             :     {
    1527          12 :         case sheet::GeneralFunction_SUM:        nStrId = STR_FUN_TEXT_SUM;      break;
    1528             :         case sheet::GeneralFunction_COUNT:
    1529           0 :         case sheet::GeneralFunction_COUNTNUMS:  nStrId = STR_FUN_TEXT_COUNT;    break;
    1530           0 :         case sheet::GeneralFunction_AVERAGE:    nStrId = STR_FUN_TEXT_AVG;      break;
    1531           0 :         case sheet::GeneralFunction_MAX:        nStrId = STR_FUN_TEXT_MAX;      break;
    1532           0 :         case sheet::GeneralFunction_MIN:        nStrId = STR_FUN_TEXT_MIN;      break;
    1533           0 :         case sheet::GeneralFunction_PRODUCT:    nStrId = STR_FUN_TEXT_PRODUCT;  break;
    1534             :         case sheet::GeneralFunction_STDEV:
    1535           0 :         case sheet::GeneralFunction_STDEVP:     nStrId = STR_FUN_TEXT_STDDEV;   break;
    1536             :         case sheet::GeneralFunction_VAR:
    1537           0 :         case sheet::GeneralFunction_VARP:       nStrId = STR_FUN_TEXT_VAR;      break;
    1538             :         case sheet::GeneralFunction_NONE:
    1539             :         case sheet::GeneralFunction_AUTO:
    1540             :         default:
    1541             :         {
    1542             :             OSL_FAIL("wrong function");
    1543             :         }
    1544             :     }
    1545         339 :     if ( !nStrId )
    1546         327 :         return OUString();
    1547             : 
    1548          12 :     OUStringBuffer aRet( ScGlobal::GetRscString( nStrId ) );
    1549          12 :     aRet.append(" - ");
    1550          12 :     aRet.append(rSourceName);
    1551          12 :     return aRet.makeStringAndClear();
    1552             : }
    1553             : 
    1554             : }
    1555             : 
    1556         339 : void ScDPOutput::GetDataDimensionNames(
    1557             :     OUString& rSourceName, OUString& rGivenName, const uno::Reference<uno::XInterface>& xDim )
    1558             : {
    1559         339 :     uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
    1560         678 :     uno::Reference<container::XNamed> xDimName( xDim, uno::UNO_QUERY );
    1561         339 :     if ( xDimProp.is() && xDimName.is() )
    1562             :     {
    1563             :         // Asterisks are added in ScDPSaveData::WriteToSource to create unique names.
    1564             :         //! preserve original name there?
    1565         339 :         rSourceName = ScDPUtil::getSourceDimensionName(xDimName->getName());
    1566             : 
    1567             :         // Generate "given name" the same way as in dptabres.
    1568             :         //! Should use a stored name when available
    1569             : 
    1570             :         sheet::GeneralFunction eFunc = (sheet::GeneralFunction)ScUnoHelpFunctions::GetEnumProperty(
    1571             :                                 xDimProp, OUString(SC_UNO_DP_FUNCTION),
    1572         339 :                                 sheet::GeneralFunction_NONE );
    1573         339 :         rGivenName = lcl_GetDataFieldName( rSourceName, eFunc );
    1574         339 :     }
    1575         339 : }
    1576             : 
    1577           0 : bool ScDPOutput::IsFilterButton( const ScAddress& rPos )
    1578             : {
    1579           0 :     SCCOL nCol = rPos.Col();
    1580           0 :     SCROW nRow = rPos.Row();
    1581           0 :     SCTAB nTab = rPos.Tab();
    1582           0 :     if ( nTab != aStartPos.Tab() || !bDoFilter )
    1583           0 :         return false;                               // wrong sheet or no button at all
    1584             : 
    1585             :     //  filter button is at top left
    1586           0 :     return ( nCol == aStartPos.Col() && nRow == aStartPos.Row() );
    1587             : }
    1588             : 
    1589           1 : long ScDPOutput::GetHeaderDim( const ScAddress& rPos, sal_uInt16& rOrient )
    1590             : {
    1591           1 :     SCCOL nCol = rPos.Col();
    1592           1 :     SCROW nRow = rPos.Row();
    1593           1 :     SCTAB nTab = rPos.Tab();
    1594           1 :     if ( nTab != aStartPos.Tab() )
    1595           0 :         return -1;                                      // wrong sheet
    1596             : 
    1597             :     //  calculate output positions and sizes
    1598             : 
    1599           1 :     CalcSizes();
    1600             : 
    1601             :     //  test for column header
    1602             : 
    1603           1 :     if ( nRow == nTabStartRow && nCol >= nDataStartCol && nCol < nDataStartCol + nColFieldCount )
    1604             :     {
    1605           0 :         rOrient = sheet::DataPilotFieldOrientation_COLUMN;
    1606           0 :         long nField = nCol - nDataStartCol;
    1607           0 :         return pColFields[nField].nDim;
    1608             :     }
    1609             : 
    1610             :     //  test for row header
    1611             : 
    1612           1 :     if ( nRow+1 == nDataStartRow && nCol >= nTabStartCol && nCol < nTabStartCol + nRowFieldCount )
    1613             :     {
    1614           0 :         rOrient = sheet::DataPilotFieldOrientation_ROW;
    1615           0 :         long nField = nCol - nTabStartCol;
    1616           0 :         return pRowFields[nField].nDim;
    1617             :     }
    1618             : 
    1619             :     //  test for page field
    1620             : 
    1621           1 :     SCROW nPageStartRow = aStartPos.Row() + ( bDoFilter ? 1 : 0 );
    1622           1 :     if ( nCol == aStartPos.Col() && nRow >= nPageStartRow && nRow < nPageStartRow + nPageFieldCount )
    1623             :     {
    1624           1 :         rOrient = sheet::DataPilotFieldOrientation_PAGE;
    1625           1 :         long nField = nRow - nPageStartRow;
    1626           1 :         return pPageFields[nField].nDim;
    1627             :     }
    1628             : 
    1629             :     //! single data field (?)
    1630             : 
    1631           0 :     rOrient = sheet::DataPilotFieldOrientation_HIDDEN;
    1632           0 :     return -1;      // invalid
    1633             : }
    1634             : 
    1635           0 : bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, bool bMouseLeft, bool bMouseTop,
    1636             :                                 long nDragDim,
    1637             :                                 Rectangle& rPosRect, sal_uInt16& rOrient, long& rDimPos )
    1638             : {
    1639             :     //  Rectangle instead of ScRange for rPosRect to allow for negative values
    1640             : 
    1641           0 :     SCCOL nCol = rPos.Col();
    1642           0 :     SCROW nRow = rPos.Row();
    1643           0 :     SCTAB nTab = rPos.Tab();
    1644           0 :     if ( nTab != aStartPos.Tab() )
    1645           0 :         return false;                                       // wrong sheet
    1646             : 
    1647             :     //  calculate output positions and sizes
    1648             : 
    1649           0 :     CalcSizes();
    1650             : 
    1651             :     //  test for column header
    1652             : 
    1653           0 :     if ( nCol >= nDataStartCol && nCol <= nTabEndCol &&
    1654           0 :             nRow + 1 >= nMemberStartRow && nRow < nMemberStartRow + nColFieldCount )
    1655             :     {
    1656           0 :         long nField = nRow - nMemberStartRow;
    1657           0 :         if (nField < 0)
    1658             :         {
    1659           0 :             nField = 0;
    1660           0 :             bMouseTop = true;
    1661             :         }
    1662             :         //! find start of dimension
    1663             : 
    1664             :         rPosRect = Rectangle( nDataStartCol, nMemberStartRow + nField,
    1665           0 :                               nTabEndCol, nMemberStartRow + nField -1 );
    1666             : 
    1667           0 :         bool bFound = false;            // is this within the same orientation?
    1668           0 :         bool bBeforeDrag = false;
    1669           0 :         bool bAfterDrag = false;
    1670           0 :         for (long nPos=0; nPos<nColFieldCount && !bFound; nPos++)
    1671             :         {
    1672           0 :             if (pColFields[nPos].nDim == nDragDim)
    1673             :             {
    1674           0 :                 bFound = true;
    1675           0 :                 if ( nField < nPos )
    1676           0 :                     bBeforeDrag = true;
    1677           0 :                 else if ( nField > nPos )
    1678           0 :                     bAfterDrag = true;
    1679             :             }
    1680             :         }
    1681             : 
    1682           0 :         if ( bFound )
    1683             :         {
    1684           0 :             if (!bBeforeDrag)
    1685             :             {
    1686           0 :                 ++rPosRect.Bottom();
    1687           0 :                 if (bAfterDrag)
    1688           0 :                     ++rPosRect.Top();
    1689             :             }
    1690             :         }
    1691             :         else
    1692             :         {
    1693           0 :             if ( !bMouseTop )
    1694             :             {
    1695           0 :                 ++rPosRect.Top();
    1696           0 :                 ++rPosRect.Bottom();
    1697           0 :                 ++nField;
    1698             :             }
    1699             :         }
    1700             : 
    1701           0 :         rOrient = sheet::DataPilotFieldOrientation_COLUMN;
    1702           0 :         rDimPos = nField;                       //!...
    1703           0 :         return true;
    1704             :     }
    1705             : 
    1706             :     //  test for row header
    1707             : 
    1708             :     //  special case if no row fields
    1709           0 :     bool bSpecial = ( nRow+1 >= nDataStartRow && nRow <= nTabEndRow &&
    1710           0 :                         nRowFieldCount == 0 && nCol == nTabStartCol && bMouseLeft );
    1711             : 
    1712           0 :     if ( bSpecial || ( nRow+1 >= nDataStartRow && nRow <= nTabEndRow &&
    1713           0 :                         nCol + 1 >= nTabStartCol && nCol < nTabStartCol + nRowFieldCount ) )
    1714             :     {
    1715           0 :         long nField = nCol - nTabStartCol;
    1716             :         //! find start of dimension
    1717             : 
    1718             :         rPosRect = Rectangle( nTabStartCol + nField, nDataStartRow - 1,
    1719           0 :                               nTabStartCol + nField - 1, nTabEndRow );
    1720             : 
    1721           0 :         bool bFound = false;            // is this within the same orientation?
    1722           0 :         bool bBeforeDrag = false;
    1723           0 :         bool bAfterDrag = false;
    1724           0 :         for (long nPos=0; nPos<nRowFieldCount && !bFound; nPos++)
    1725             :         {
    1726           0 :             if (pRowFields[nPos].nDim == nDragDim)
    1727             :             {
    1728           0 :                 bFound = true;
    1729           0 :                 if ( nField < nPos )
    1730           0 :                     bBeforeDrag = true;
    1731           0 :                 else if ( nField > nPos )
    1732           0 :                     bAfterDrag = true;
    1733             :             }
    1734             :         }
    1735             : 
    1736           0 :         if ( bFound )
    1737             :         {
    1738           0 :             if (!bBeforeDrag)
    1739             :             {
    1740           0 :                 ++rPosRect.Right();
    1741           0 :                 if (bAfterDrag)
    1742           0 :                     ++rPosRect.Left();
    1743             :             }
    1744             :         }
    1745             :         else
    1746             :         {
    1747           0 :             if ( !bMouseLeft )
    1748             :             {
    1749           0 :                 ++rPosRect.Left();
    1750           0 :                 ++rPosRect.Right();
    1751           0 :                 ++nField;
    1752             :             }
    1753             :         }
    1754             : 
    1755           0 :         rOrient = sheet::DataPilotFieldOrientation_ROW;
    1756           0 :         rDimPos = nField;                       //!...
    1757           0 :         return true;
    1758             :     }
    1759             : 
    1760             :     //  test for page fields
    1761             : 
    1762           0 :     SCROW nPageStartRow = aStartPos.Row() + ( bDoFilter ? 1 : 0 );
    1763           0 :     if ( nCol >= aStartPos.Col() && nCol <= nTabEndCol &&
    1764           0 :             nRow + 1 >= nPageStartRow && nRow < nPageStartRow + nPageFieldCount )
    1765             :     {
    1766           0 :         long nField = nRow - nPageStartRow;
    1767           0 :         if (nField < 0)
    1768             :         {
    1769           0 :             nField = 0;
    1770           0 :             bMouseTop = true;
    1771             :         }
    1772             :         //! find start of dimension
    1773             : 
    1774           0 :         rPosRect = Rectangle( aStartPos.Col(), nPageStartRow + nField,
    1775           0 :                               nTabEndCol, nPageStartRow + nField - 1 );
    1776             : 
    1777           0 :         bool bFound = false;            // is this within the same orientation?
    1778           0 :         bool bBeforeDrag = false;
    1779           0 :         bool bAfterDrag = false;
    1780           0 :         for (long nPos=0; nPos<nPageFieldCount && !bFound; nPos++)
    1781             :         {
    1782           0 :             if (pPageFields[nPos].nDim == nDragDim)
    1783             :             {
    1784           0 :                 bFound = true;
    1785           0 :                 if ( nField < nPos )
    1786           0 :                     bBeforeDrag = true;
    1787           0 :                 else if ( nField > nPos )
    1788           0 :                     bAfterDrag = true;
    1789             :             }
    1790             :         }
    1791             : 
    1792           0 :         if ( bFound )
    1793             :         {
    1794           0 :             if (!bBeforeDrag)
    1795             :             {
    1796           0 :                 ++rPosRect.Bottom();
    1797           0 :                 if (bAfterDrag)
    1798           0 :                     ++rPosRect.Top();
    1799             :             }
    1800             :         }
    1801             :         else
    1802             :         {
    1803           0 :             if ( !bMouseTop )
    1804             :             {
    1805           0 :                 ++rPosRect.Top();
    1806           0 :                 ++rPosRect.Bottom();
    1807           0 :                 ++nField;
    1808             :             }
    1809             :         }
    1810             : 
    1811           0 :         rOrient = sheet::DataPilotFieldOrientation_PAGE;
    1812           0 :         rDimPos = nField;                       //!...
    1813           0 :         return true;
    1814             :     }
    1815             : 
    1816           0 :     return false;
    1817         102 : }
    1818             : 
    1819             : 
    1820             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10