LCOV - code coverage report
Current view: top level - sc/source/ui/view - pivotsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 73 21.9 %
Date: 2012-08-25 Functions: 8 17 47.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 18 145 12.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "scitems.hxx"
      30                 :            : #include <svl/srchitem.hxx>
      31                 :            : #include <sfx2/app.hxx>
      32                 :            : #include <sfx2/objface.hxx>
      33                 :            : #include <sfx2/objsh.hxx>
      34                 :            : #include <sfx2/request.hxx>
      35                 :            : #include <svl/whiter.hxx>
      36                 :            : #include <vcl/msgbox.hxx>
      37                 :            : 
      38                 :            : #include "sc.hrc"
      39                 :            : #include "pivotsh.hxx"
      40                 :            : #include "tabvwsh.hxx"
      41                 :            : #include "docsh.hxx"
      42                 :            : #include "scresid.hxx"
      43                 :            : #include "document.hxx"
      44                 :            : #include "dpobject.hxx"
      45                 :            : #include "dpshttab.hxx"
      46                 :            : #include "dbdocfun.hxx"
      47                 :            : #include "uiitems.hxx"
      48                 :            : #include "scabstdlg.hxx"
      49                 :            : //------------------------------------------------------------------------
      50                 :            : 
      51                 :            : #define ScPivotShell
      52                 :            : #include "scslots.hxx"
      53                 :            : 
      54                 :            : //------------------------------------------------------------------------
      55                 :            : 
      56 [ #  # ][ #  # ]:          0 : TYPEINIT1( ScPivotShell, SfxShell );
      57                 :            : 
      58 [ +  + ][ +  - ]:        153 : SFX_IMPL_INTERFACE(ScPivotShell, SfxShell, ScResId(SCSTR_PIVOTSHELL))
                 [ +  - ]
      59                 :            : {
      60 [ +  - ][ +  - ]:         51 :     SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_PIVOT) );
      61                 :         51 : }
      62                 :            : 
      63                 :            : 
      64                 :            : //------------------------------------------------------------------------
      65                 :            : 
      66                 :          2 : ScPivotShell::ScPivotShell( ScTabViewShell* pViewSh ) :
      67                 :            :     SfxShell(pViewSh),
      68                 :          2 :     pViewShell( pViewSh )
      69                 :            : {
      70                 :          2 :     SetPool( &pViewSh->GetPool() );
      71                 :          2 :     ScViewData* pViewData = pViewSh->GetViewData();
      72 [ +  - ][ +  - ]:          2 :     ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
      73         [ +  - ]:          2 :     SetUndoManager( pMgr );
      74 [ +  - ][ -  + ]:          2 :     if ( !pViewData->GetDocument()->IsUndoEnabled() )
      75                 :            :     {
      76         [ #  # ]:          0 :         pMgr->SetMaxUndoActionCount( 0 );
      77                 :            :     }
      78         [ +  - ]:          2 :     SetHelpId( HID_SCSHELL_PIVOTSH );
      79 [ +  - ][ +  - ]:          2 :     SetName(rtl::OUString("Pivot"));
                 [ +  - ]
      80                 :          2 : }
      81                 :            : 
      82                 :            : //------------------------------------------------------------------------
      83                 :          2 : ScPivotShell::~ScPivotShell()
      84                 :            : {
      85         [ -  + ]:          4 : }
      86                 :            : 
      87                 :            : //------------------------------------------------------------------------
      88                 :          0 : void ScPivotShell::Execute( SfxRequest& rReq )
      89                 :            : {
      90   [ #  #  #  # ]:          0 :     switch ( rReq.GetSlot() )
      91                 :            :     {
      92                 :            :         case SID_PIVOT_RECALC:
      93                 :          0 :             pViewShell->RecalcPivotTable();
      94                 :          0 :             break;
      95                 :            : 
      96                 :            :         case SID_PIVOT_KILL:
      97                 :          0 :             pViewShell->DeletePivotTable();
      98                 :          0 :             break;
      99                 :            : 
     100                 :            :         case SID_DP_FILTER:
     101                 :            :         {
     102                 :          0 :             ScDPObject* pDPObj = GetCurrDPObject();
     103         [ #  # ]:          0 :             if( pDPObj )
     104                 :            :             {
     105         [ #  # ]:          0 :                 ScQueryParam aQueryParam;
     106                 :          0 :                 SCTAB nSrcTab = 0;
     107                 :          0 :                 const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc();
     108                 :            :                 OSL_ENSURE( pDesc, "no sheet source for DP filter dialog" );
     109         [ #  # ]:          0 :                 if( pDesc )
     110                 :            :                 {
     111 [ #  # ][ #  # ]:          0 :                     aQueryParam = pDesc->GetQueryParam();
     112         [ #  # ]:          0 :                     nSrcTab = pDesc->GetSourceRange().aStart.Tab();
     113                 :            :                 }
     114                 :            : 
     115                 :          0 :                 ScViewData* pViewData = pViewShell->GetViewData();
     116                 :          0 :                 SfxItemSet aArgSet( pViewShell->GetPool(),
     117         [ #  # ]:          0 :                     SCITEM_QUERYDATA, SCITEM_QUERYDATA );
     118 [ #  # ][ #  # ]:          0 :                 aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, pViewData, &aQueryParam ) );
                 [ #  # ]
     119                 :            : 
     120         [ #  # ]:          0 :                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     121                 :            :                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     122                 :            : 
     123                 :            :                 AbstractScPivotFilterDlg* pDlg = pFact->CreateScPivotFilterDlg( pViewShell->GetDialogParent(),
     124                 :            :                                                                                 aArgSet, nSrcTab,
     125 [ #  # ][ #  # ]:          0 :                                                                                 RID_SCDLG_PIVOTFILTER);
     126                 :            :                 OSL_ENSURE(pDlg, "Dialog create fail!");
     127                 :            : 
     128 [ #  # ][ #  # ]:          0 :                 if( pDlg->Execute() == RET_OK )
     129                 :            :                 {
     130 [ #  # ][ #  # ]:          0 :                     ScSheetSourceDesc aNewDesc(pViewData->GetDocument());
     131         [ #  # ]:          0 :                     if( pDesc )
     132         [ #  # ]:          0 :                         aNewDesc = *pDesc;
     133                 :            : 
     134         [ #  # ]:          0 :                     const ScQueryItem& rQueryItem = pDlg->GetOutputItem();
     135 [ #  # ][ #  # ]:          0 :                     aNewDesc.SetQueryParam(rQueryItem.GetQueryData());
     136                 :            : 
     137         [ #  # ]:          0 :                     ScDPObject aNewObj( *pDPObj );
     138         [ #  # ]:          0 :                     aNewObj.SetSheetDesc( aNewDesc );
     139                 :          0 :                     ScDBDocFunc aFunc( *pViewData->GetDocShell() );
     140         [ #  # ]:          0 :                     aFunc.DataPilotUpdate( pDPObj, &aNewObj, sal_True, false );
     141 [ #  # ][ #  # ]:          0 :                     pViewData->GetView()->CursorPosChanged();       // shells may be switched
                 [ #  # ]
     142                 :            :                 }
     143 [ #  # ][ #  # ]:          0 :                 delete pDlg;
         [ #  # ][ #  # ]
     144                 :            :             }
     145                 :            :         }
     146                 :          0 :         break;
     147                 :            :     }
     148                 :          0 : }
     149                 :            : 
     150                 :            : //------------------------------------------------------------------------
     151                 :          0 : void ScPivotShell::GetState( SfxItemSet& rSet )
     152                 :            : {
     153                 :          0 :     ScDocShell* pDocSh = pViewShell->GetViewData()->GetDocShell();
     154                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
     155 [ #  # ][ #  # ]:          0 :     sal_Bool bDisable = pDocSh->IsReadOnly() || pDoc->GetChangeTrack();
                 [ #  # ]
     156                 :            : 
     157         [ #  # ]:          0 :     SfxWhichIter aIter(rSet);
     158         [ #  # ]:          0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     159         [ #  # ]:          0 :     while (nWhich)
     160                 :            :     {
     161      [ #  #  # ]:          0 :         switch (nWhich)
     162                 :            :         {
     163                 :            :             case SID_PIVOT_RECALC:
     164                 :            :             case SID_PIVOT_KILL:
     165                 :            :             {
     166                 :            :                 //! move ReadOnly check to idl flags
     167         [ #  # ]:          0 :                 if ( bDisable )
     168                 :            :                 {
     169         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     170                 :            :                 }
     171                 :            :             }
     172                 :          0 :             break;
     173                 :            :             case SID_DP_FILTER:
     174                 :            :             {
     175         [ #  # ]:          0 :                 ScDPObject* pDPObj = GetCurrDPObject();
     176 [ #  # ][ #  # ]:          0 :                 if( bDisable || !pDPObj || !pDPObj->IsSheetData() )
         [ #  # ][ #  # ]
                 [ #  # ]
     177         [ #  # ]:          0 :                     rSet.DisableItem( nWhich );
     178                 :            :             }
     179                 :          0 :             break;
     180                 :            :         }
     181         [ #  # ]:          0 :         nWhich = aIter.NextWhich();
     182         [ #  # ]:          0 :     }
     183                 :          0 : }
     184                 :            : 
     185                 :            : 
     186                 :            : //------------------------------------------------------------------------
     187                 :            : 
     188                 :          0 : ScDPObject* ScPivotShell::GetCurrDPObject()
     189                 :            : {
     190                 :          0 :     const ScViewData& rViewData = *pViewShell->GetViewData();
     191                 :            :     return rViewData.GetDocument()->GetDPAtCursor(
     192                 :          0 :         rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() );
     193 [ +  - ][ +  - ]:        153 : }
     194                 :            : 
     195                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10