LCOV - code coverage report
Current view: top level - sc/source/ui/view - pivotsh.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 74 0.0 %
Date: 2014-04-14 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "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             : #define ScPivotShell
      43             : #include "scslots.hxx"
      44             : 
      45           0 : TYPEINIT1( ScPivotShell, SfxShell );
      46             : 
      47           0 : SFX_IMPL_INTERFACE(ScPivotShell, SfxShell, ScResId(SCSTR_PIVOTSHELL))
      48             : {
      49           0 :     SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_PIVOT) );
      50           0 : }
      51             : 
      52           0 : ScPivotShell::ScPivotShell( ScTabViewShell* pViewSh ) :
      53             :     SfxShell(pViewSh),
      54           0 :     pViewShell( pViewSh )
      55             : {
      56           0 :     SetPool( &pViewSh->GetPool() );
      57           0 :     ScViewData* pViewData = pViewSh->GetViewData();
      58           0 :     ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
      59           0 :     SetUndoManager( pMgr );
      60           0 :     if ( !pViewData->GetDocument()->IsUndoEnabled() )
      61             :     {
      62           0 :         pMgr->SetMaxUndoActionCount( 0 );
      63             :     }
      64           0 :     SetHelpId( HID_SCSHELL_PIVOTSH );
      65           0 :     SetName(OUString("Pivot"));
      66           0 :     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Pivot));
      67           0 : }
      68             : 
      69           0 : ScPivotShell::~ScPivotShell()
      70             : {
      71           0 : }
      72             : 
      73           0 : void ScPivotShell::Execute( SfxRequest& rReq )
      74             : {
      75           0 :     switch ( rReq.GetSlot() )
      76             :     {
      77             :         case SID_PIVOT_RECALC:
      78           0 :             pViewShell->RecalcPivotTable();
      79           0 :             break;
      80             : 
      81             :         case SID_PIVOT_KILL:
      82           0 :             pViewShell->DeletePivotTable();
      83           0 :             break;
      84             : 
      85             :         case SID_DP_FILTER:
      86             :         {
      87           0 :             ScDPObject* pDPObj = GetCurrDPObject();
      88           0 :             if( pDPObj )
      89             :             {
      90           0 :                 ScQueryParam aQueryParam;
      91           0 :                 SCTAB nSrcTab = 0;
      92           0 :                 const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc();
      93             :                 OSL_ENSURE( pDesc, "no sheet source for DP filter dialog" );
      94           0 :                 if( pDesc )
      95             :                 {
      96           0 :                     aQueryParam = pDesc->GetQueryParam();
      97           0 :                     nSrcTab = pDesc->GetSourceRange().aStart.Tab();
      98             :                 }
      99             : 
     100           0 :                 ScViewData* pViewData = pViewShell->GetViewData();
     101           0 :                 SfxItemSet aArgSet( pViewShell->GetPool(),
     102           0 :                     SCITEM_QUERYDATA, SCITEM_QUERYDATA );
     103           0 :                 aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, pViewData, &aQueryParam ) );
     104             : 
     105           0 :                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     106             :                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     107             : 
     108             :                 AbstractScPivotFilterDlg* pDlg = pFact->CreateScPivotFilterDlg(
     109           0 :                     pViewShell->GetDialogParent(), aArgSet, nSrcTab);
     110             :                 OSL_ENSURE(pDlg, "Dialog create fail!");
     111             : 
     112           0 :                 if( pDlg->Execute() == RET_OK )
     113             :                 {
     114           0 :                     ScSheetSourceDesc aNewDesc(pViewData->GetDocument());
     115           0 :                     if( pDesc )
     116           0 :                         aNewDesc = *pDesc;
     117             : 
     118           0 :                     const ScQueryItem& rQueryItem = pDlg->GetOutputItem();
     119           0 :                     aNewDesc.SetQueryParam(rQueryItem.GetQueryData());
     120             : 
     121           0 :                     ScDPObject aNewObj( *pDPObj );
     122           0 :                     aNewObj.SetSheetDesc( aNewDesc );
     123           0 :                     ScDBDocFunc aFunc( *pViewData->GetDocShell() );
     124           0 :                     aFunc.DataPilotUpdate( pDPObj, &aNewObj, true, false );
     125           0 :                     pViewData->GetView()->CursorPosChanged();       // shells may be switched
     126             :                 }
     127           0 :                 delete pDlg;
     128             :             }
     129             :         }
     130           0 :         break;
     131             :     }
     132           0 : }
     133             : 
     134           0 : void ScPivotShell::GetState( SfxItemSet& rSet )
     135             : {
     136           0 :     ScDocShell* pDocSh = pViewShell->GetViewData()->GetDocShell();
     137           0 :     ScDocument* pDoc = pDocSh->GetDocument();
     138           0 :     sal_Bool bDisable = pDocSh->IsReadOnly() || pDoc->GetChangeTrack();
     139             : 
     140           0 :     SfxWhichIter aIter(rSet);
     141           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     142           0 :     while (nWhich)
     143             :     {
     144           0 :         switch (nWhich)
     145             :         {
     146             :             case SID_PIVOT_RECALC:
     147             :             case SID_PIVOT_KILL:
     148             :             {
     149             :                 //! move ReadOnly check to idl flags
     150           0 :                 if ( bDisable )
     151             :                 {
     152           0 :                     rSet.DisableItem( nWhich );
     153             :                 }
     154             :             }
     155           0 :             break;
     156             :             case SID_DP_FILTER:
     157             :             {
     158           0 :                 ScDPObject* pDPObj = GetCurrDPObject();
     159           0 :                 if( bDisable || !pDPObj || !pDPObj->IsSheetData() )
     160           0 :                     rSet.DisableItem( nWhich );
     161             :             }
     162           0 :             break;
     163             :         }
     164           0 :         nWhich = aIter.NextWhich();
     165           0 :     }
     166           0 : }
     167             : 
     168           0 : ScDPObject* ScPivotShell::GetCurrDPObject()
     169             : {
     170           0 :     const ScViewData& rViewData = *pViewShell->GetViewData();
     171             :     return rViewData.GetDocument()->GetDPAtCursor(
     172           0 :         rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() );
     173           0 : }
     174             : 
     175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10