LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/view - pivotsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 74 23.0 %
Date: 2013-07-09 Functions: 8 17 47.1 %
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 <svl/srchitem.hxx>
      22             : #include <sfx2/app.hxx>
      23             : #include <sfx2/objface.hxx>
      24             : #include <sfx2/objsh.hxx>
      25             : #include <sfx2/request.hxx>
      26             : #include <svl/whiter.hxx>
      27             : #include <vcl/msgbox.hxx>
      28             : #include <sfx2/sidebar/EnumContext.hxx>
      29             : 
      30             : #include "sc.hrc"
      31             : #include "pivotsh.hxx"
      32             : #include "tabvwsh.hxx"
      33             : #include "docsh.hxx"
      34             : #include "scresid.hxx"
      35             : #include "document.hxx"
      36             : #include "dpobject.hxx"
      37             : #include "dpshttab.hxx"
      38             : #include "dbdocfun.hxx"
      39             : #include "uiitems.hxx"
      40             : #include "scabstdlg.hxx"
      41             : //------------------------------------------------------------------------
      42             : 
      43             : #define ScPivotShell
      44             : #include "scslots.hxx"
      45             : 
      46             : //------------------------------------------------------------------------
      47             : 
      48           0 : TYPEINIT1( ScPivotShell, SfxShell );
      49             : 
      50         124 : SFX_IMPL_INTERFACE(ScPivotShell, SfxShell, ScResId(SCSTR_PIVOTSHELL))
      51             : {
      52          31 :     SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_PIVOT) );
      53          31 : }
      54             : 
      55             : 
      56             : //------------------------------------------------------------------------
      57             : 
      58           1 : ScPivotShell::ScPivotShell( ScTabViewShell* pViewSh ) :
      59             :     SfxShell(pViewSh),
      60           1 :     pViewShell( pViewSh )
      61             : {
      62           1 :     SetPool( &pViewSh->GetPool() );
      63           1 :     ScViewData* pViewData = pViewSh->GetViewData();
      64           1 :     ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
      65           1 :     SetUndoManager( pMgr );
      66           1 :     if ( !pViewData->GetDocument()->IsUndoEnabled() )
      67             :     {
      68           0 :         pMgr->SetMaxUndoActionCount( 0 );
      69             :     }
      70           1 :     SetHelpId( HID_SCSHELL_PIVOTSH );
      71           1 :     SetName(OUString("Pivot"));
      72           1 :     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Pivot));
      73           1 : }
      74             : 
      75             : //------------------------------------------------------------------------
      76           2 : ScPivotShell::~ScPivotShell()
      77             : {
      78           2 : }
      79             : 
      80             : //------------------------------------------------------------------------
      81           0 : void ScPivotShell::Execute( SfxRequest& rReq )
      82             : {
      83           0 :     switch ( rReq.GetSlot() )
      84             :     {
      85             :         case SID_PIVOT_RECALC:
      86           0 :             pViewShell->RecalcPivotTable();
      87           0 :             break;
      88             : 
      89             :         case SID_PIVOT_KILL:
      90           0 :             pViewShell->DeletePivotTable();
      91           0 :             break;
      92             : 
      93             :         case SID_DP_FILTER:
      94             :         {
      95           0 :             ScDPObject* pDPObj = GetCurrDPObject();
      96           0 :             if( pDPObj )
      97             :             {
      98           0 :                 ScQueryParam aQueryParam;
      99           0 :                 SCTAB nSrcTab = 0;
     100           0 :                 const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc();
     101             :                 OSL_ENSURE( pDesc, "no sheet source for DP filter dialog" );
     102           0 :                 if( pDesc )
     103             :                 {
     104           0 :                     aQueryParam = pDesc->GetQueryParam();
     105           0 :                     nSrcTab = pDesc->GetSourceRange().aStart.Tab();
     106             :                 }
     107             : 
     108           0 :                 ScViewData* pViewData = pViewShell->GetViewData();
     109           0 :                 SfxItemSet aArgSet( pViewShell->GetPool(),
     110           0 :                     SCITEM_QUERYDATA, SCITEM_QUERYDATA );
     111           0 :                 aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, pViewData, &aQueryParam ) );
     112             : 
     113           0 :                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     114             :                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     115             : 
     116             :                 AbstractScPivotFilterDlg* pDlg = pFact->CreateScPivotFilterDlg( pViewShell->GetDialogParent(),
     117             :                                                                                 aArgSet, nSrcTab,
     118           0 :                                                                                 RID_SCDLG_PIVOTFILTER);
     119             :                 OSL_ENSURE(pDlg, "Dialog create fail!");
     120             : 
     121           0 :                 if( pDlg->Execute() == RET_OK )
     122             :                 {
     123           0 :                     ScSheetSourceDesc aNewDesc(pViewData->GetDocument());
     124           0 :                     if( pDesc )
     125           0 :                         aNewDesc = *pDesc;
     126             : 
     127           0 :                     const ScQueryItem& rQueryItem = pDlg->GetOutputItem();
     128           0 :                     aNewDesc.SetQueryParam(rQueryItem.GetQueryData());
     129             : 
     130           0 :                     ScDPObject aNewObj( *pDPObj );
     131           0 :                     aNewObj.SetSheetDesc( aNewDesc );
     132           0 :                     ScDBDocFunc aFunc( *pViewData->GetDocShell() );
     133           0 :                     aFunc.DataPilotUpdate( pDPObj, &aNewObj, sal_True, false );
     134           0 :                     pViewData->GetView()->CursorPosChanged();       // shells may be switched
     135             :                 }
     136           0 :                 delete pDlg;
     137             :             }
     138             :         }
     139           0 :         break;
     140             :     }
     141           0 : }
     142             : 
     143             : //------------------------------------------------------------------------
     144           0 : void ScPivotShell::GetState( SfxItemSet& rSet )
     145             : {
     146           0 :     ScDocShell* pDocSh = pViewShell->GetViewData()->GetDocShell();
     147           0 :     ScDocument* pDoc = pDocSh->GetDocument();
     148           0 :     sal_Bool bDisable = pDocSh->IsReadOnly() || pDoc->GetChangeTrack();
     149             : 
     150           0 :     SfxWhichIter aIter(rSet);
     151           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     152           0 :     while (nWhich)
     153             :     {
     154           0 :         switch (nWhich)
     155             :         {
     156             :             case SID_PIVOT_RECALC:
     157             :             case SID_PIVOT_KILL:
     158             :             {
     159             :                 //! move ReadOnly check to idl flags
     160           0 :                 if ( bDisable )
     161             :                 {
     162           0 :                     rSet.DisableItem( nWhich );
     163             :                 }
     164             :             }
     165           0 :             break;
     166             :             case SID_DP_FILTER:
     167             :             {
     168           0 :                 ScDPObject* pDPObj = GetCurrDPObject();
     169           0 :                 if( bDisable || !pDPObj || !pDPObj->IsSheetData() )
     170           0 :                     rSet.DisableItem( nWhich );
     171             :             }
     172           0 :             break;
     173             :         }
     174           0 :         nWhich = aIter.NextWhich();
     175           0 :     }
     176           0 : }
     177             : 
     178             : 
     179             : //------------------------------------------------------------------------
     180             : 
     181           0 : ScDPObject* ScPivotShell::GetCurrDPObject()
     182             : {
     183           0 :     const ScViewData& rViewData = *pViewShell->GetViewData();
     184             :     return rViewData.GetDocument()->GetDPAtCursor(
     185           0 :         rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() );
     186          93 : }
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10