LibreOffice Module sc (master) 1
pivotsh.cxx
Go to the documentation of this file.
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 <sfx2/objface.hxx>
22#include <sfx2/objsh.hxx>
23#include <sfx2/request.hxx>
24#include <svl/whiter.hxx>
25#include <vcl/EnumContext.hxx>
26
27#include <sc.hrc>
28#include <pivotsh.hxx>
29#include <tabvwsh.hxx>
30#include <docsh.hxx>
31#include <document.hxx>
32#include <dpobject.hxx>
33#include <dpshttab.hxx>
34#include <dbdocfun.hxx>
35#include <uiitems.hxx>
36#include <scabstdlg.hxx>
37
38#define ShellClass_ScPivotShell
39#include <scslots.hxx>
40
41
43
44void ScPivotShell::InitInterface_Impl()
45{
46 GetStaticInterface()->RegisterPopupMenu("pivot");
47}
48
50 SfxShell(pViewSh),
51 pViewShell( pViewSh )
52{
53 SetPool( &pViewSh->GetPool() );
54 ScViewData& rViewData = pViewSh->GetViewData();
55 SfxUndoManager* pMgr = rViewData.GetSfxDocShell()->GetUndoManager();
56 SetUndoManager( pMgr );
57 if ( !rViewData.GetDocument().IsUndoEnabled() )
58 {
59 pMgr->SetMaxUndoActionCount( 0 );
60 }
61 SetName("Pivot");
63}
64
66{
67}
68
70{
71 switch ( rReq.GetSlot() )
72 {
73 case SID_PIVOT_RECALC:
75 break;
76
77 case SID_PIVOT_KILL:
79 break;
80
81 case SID_DP_FILTER:
82 {
83 ScDPObject* pDPObj = GetCurrDPObject();
84 if( pDPObj )
85 {
86 ScQueryParam aQueryParam;
87 SCTAB nSrcTab = 0;
88 const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc();
89 OSL_ENSURE( pDesc, "no sheet source for DP filter dialog" );
90 if( pDesc )
91 {
92 aQueryParam = pDesc->GetQueryParam();
93 nSrcTab = pDesc->GetSourceRange().aStart.Tab();
94 }
95
96 ScViewData& rViewData = pViewShell->GetViewData();
98 aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, &rViewData, &aQueryParam ) );
99
101
103 pViewShell->GetFrameWeld(), aArgSet, nSrcTab));
104
105 if( pDlg->Execute() == RET_OK )
106 {
107 ScSheetSourceDesc aNewDesc(&rViewData.GetDocument());
108 if( pDesc )
109 aNewDesc = *pDesc;
110
111 const ScQueryItem& rQueryItem = pDlg->GetOutputItem();
112 aNewDesc.SetQueryParam(rQueryItem.GetQueryData());
113
114 ScDPObject aNewObj( *pDPObj );
115 aNewObj.SetSheetDesc( aNewDesc );
116 ScDBDocFunc aFunc( *rViewData.GetDocShell() );
117 aFunc.DataPilotUpdate( pDPObj, &aNewObj, true, false );
118 rViewData.GetView()->CursorPosChanged(); // shells may be switched
119 }
120 }
121 }
122 break;
123 }
124}
125
127{
129 ScDocument& rDoc = pDocSh->GetDocument();
130 bool bDisable = pDocSh->IsReadOnly() || rDoc.GetChangeTrack();
131
132 SfxWhichIter aIter(rSet);
133 sal_uInt16 nWhich = aIter.FirstWhich();
134 while (nWhich)
135 {
136 switch (nWhich)
137 {
138 case SID_PIVOT_RECALC:
139 case SID_PIVOT_KILL:
140 {
142 if ( bDisable )
143 {
144 rSet.DisableItem( nWhich );
145 }
146 }
147 break;
148 case SID_DP_FILTER:
149 {
150 ScDPObject* pDPObj = GetCurrDPObject();
151 if( bDisable || !pDPObj || !pDPObj->IsSheetData() )
152 rSet.DisableItem( nWhich );
153 }
154 break;
155 }
156 nWhich = aIter.NextWhich();
157 }
158}
159
161{
162 const ScViewData& rViewData = pViewShell->GetViewData();
163 return rViewData.GetDocument().GetDPAtCursor(
164 rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() );
165}
166
167/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual VclPtr< AbstractScPivotFilterDlg > CreateScPivotFilterDlg(weld::Window *pParent, const SfxItemSet &rArgSet, sal_uInt16 nSourceTab)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:37
SCTAB Tab() const
Definition: address.hxx:283
bool DataPilotUpdate(ScDPObject *pOldObj, const ScDPObject *pNewObj, bool bRecord, bool bApi, bool bAllowMove=false)
Definition: dbdocfun.cxx:1297
void DeletePivotTable()
Definition: dbfunc3.cxx:706
void RecalcPivotTable()
Definition: dbfunc3.cxx:723
void SetSheetDesc(const ScSheetSourceDesc &rDesc)
Definition: dpobject.cxx:415
const ScSheetSourceDesc * GetSheetDesc() const
Definition: dpobject.hxx:156
bool IsSheetData() const
Definition: dpobject.cxx:485
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
SC_DLLPUBLIC ScDPObject * GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: documen3.cxx:377
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2494
bool IsUndoEnabled() const
Definition: document.hxx:1595
virtual ~ScPivotShell() override
Definition: pivotsh.cxx:65
void GetState(SfxItemSet &rSet)
Definition: pivotsh.cxx:126
void Execute(const SfxRequest &rReq)
Definition: pivotsh.cxx:69
ScDPObject * GetCurrDPObject()
Definition: pivotsh.cxx:160
ScPivotShell(ScTabViewShell *pView)
Definition: pivotsh.cxx:49
ScTabViewShell * pViewShell
Definition: pivotsh.hxx:47
const ScQueryParam & GetQueryData() const
Definition: uiitems.cxx:215
ScAddress aStart
Definition: address.hxx:497
This class contains authoritative information on the internal reference used as the data source for d...
Definition: dpshttab.hxx:40
const ScQueryParam & GetQueryParam() const
Definition: dpshttab.hxx:63
SC_DLLPUBLIC const ScRange & GetSourceRange() const
Get the range that contains the source data.
Definition: dpshttab.cxx:230
void SetQueryParam(const ScQueryParam &rParam)
Definition: dpshttab.cxx:270
ScViewData & GetViewData()
Definition: tabview.hxx:344
void CursorPosChanged()
Definition: tabview3.cxx:626
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
ScDBFunc * GetView() const
Definition: viewdata.cxx:864
SfxObjectShell * GetSfxDocShell() const
Definition: viewdata.hxx:358
SCROW GetCurY() const
Definition: viewdata.hxx:402
SCCOL GetCurX() const
Definition: viewdata.hxx:401
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void DisableItem(sal_uInt16 nWhich)
bool IsReadOnly() const
sal_uInt16 GetSlot() const
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
SfxItemPool & GetPool() const
void SetContextName(const OUString &rsContextName)
virtual SfxUndoManager * GetUndoManager()
void SetPool(SfxItemPool *pNewPool)
void SetName(const OUString &rName)
void SetMaxUndoActionCount(size_t nMaxUndoActionCount)
weld::Window * GetFrameWeld() const
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
static const OUString & GetContextName(const Context eContext)
#define SCITEM_QUERYDATA
Definition: scitems.hxx:91
static SfxItemSet & rSet
#define SFX_IMPL_INTERFACE(Class, SuperClass)
sal_Int16 SCTAB
Definition: types.hxx:22
RET_OK