2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-30 12:23:25 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include "scitems.hxx"
|
2009-12-10 23:06:35 +01:00
|
|
|
#include <svl/srchitem.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sfx2/app.hxx>
|
|
|
|
#include <sfx2/objface.hxx>
|
|
|
|
#include <sfx2/objsh.hxx>
|
|
|
|
#include <sfx2/request.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/whiter.hxx>
|
2002-05-30 13:36:32 +00:00
|
|
|
#include <vcl/msgbox.hxx>
|
2013-04-10 08:20:16 +00:00
|
|
|
#include <sfx2/sidebar/EnumContext.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-05-30 13:36:32 +00:00
|
|
|
#include "sc.hrc"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "pivotsh.hxx"
|
|
|
|
#include "tabvwsh.hxx"
|
2002-05-30 13:36:32 +00:00
|
|
|
#include "docsh.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "scresid.hxx"
|
|
|
|
#include "document.hxx"
|
2002-05-30 13:36:32 +00:00
|
|
|
#include "dpobject.hxx"
|
|
|
|
#include "dpshttab.hxx"
|
|
|
|
#include "dbdocfun.hxx"
|
|
|
|
#include "uiitems.hxx"
|
2010-10-01 17:50:24 +13:00
|
|
|
#include "scabstdlg.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#define ScPivotShell
|
|
|
|
#include "scslots.hxx"
|
2014-05-11 01:36:27 +09:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
TYPEINIT1( ScPivotShell, SfxShell );
|
|
|
|
|
2014-11-25 10:12:55 +00:00
|
|
|
SFX_IMPL_INTERFACE(ScPivotShell, SfxShell)
|
2014-04-18 17:25:30 +02:00
|
|
|
|
|
|
|
void ScPivotShell::InitInterface_Impl()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-04-18 15:28:44 +02:00
|
|
|
GetStaticInterface()->RegisterPopupMenu(ScResId(RID_POPUP_PIVOT));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScPivotShell::ScPivotShell( ScTabViewShell* pViewSh ) :
|
|
|
|
SfxShell(pViewSh),
|
|
|
|
pViewShell( pViewSh )
|
|
|
|
{
|
|
|
|
SetPool( &pViewSh->GetPool() );
|
2014-06-18 12:14:29 +02:00
|
|
|
ScViewData& rViewData = pViewSh->GetViewData();
|
|
|
|
::svl::IUndoManager* pMgr = rViewData.GetSfxDocShell()->GetUndoManager();
|
2008-01-10 12:20:46 +00:00
|
|
|
SetUndoManager( pMgr );
|
2014-06-18 12:14:29 +02:00
|
|
|
if ( !rViewData.GetDocument()->IsUndoEnabled() )
|
2008-01-10 12:20:46 +00:00
|
|
|
{
|
|
|
|
pMgr->SetMaxUndoActionCount( 0 );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
SetHelpId( HID_SCSHELL_PIVOTSH );
|
2013-04-07 12:06:47 +02:00
|
|
|
SetName(OUString("Pivot"));
|
2013-04-10 08:20:16 +00:00
|
|
|
SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Pivot));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScPivotShell::~ScPivotShell()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScPivotShell::Execute( SfxRequest& rReq )
|
|
|
|
{
|
|
|
|
switch ( rReq.GetSlot() )
|
|
|
|
{
|
|
|
|
case SID_PIVOT_RECALC:
|
|
|
|
pViewShell->RecalcPivotTable();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SID_PIVOT_KILL:
|
|
|
|
pViewShell->DeletePivotTable();
|
|
|
|
break;
|
2002-05-30 13:36:32 +00:00
|
|
|
|
|
|
|
case SID_DP_FILTER:
|
|
|
|
{
|
|
|
|
ScDPObject* pDPObj = GetCurrDPObject();
|
|
|
|
if( pDPObj )
|
|
|
|
{
|
|
|
|
ScQueryParam aQueryParam;
|
2004-06-04 11:04:08 +00:00
|
|
|
SCTAB nSrcTab = 0;
|
2002-05-30 13:36:32 +00:00
|
|
|
const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc();
|
2011-05-21 15:04:26 +02:00
|
|
|
OSL_ENSURE( pDesc, "no sheet source for DP filter dialog" );
|
2002-05-30 13:36:32 +00:00
|
|
|
if( pDesc )
|
|
|
|
{
|
2011-01-20 20:22:52 -05:00
|
|
|
aQueryParam = pDesc->GetQueryParam();
|
2011-01-21 14:59:06 -05:00
|
|
|
nSrcTab = pDesc->GetSourceRange().aStart.Tab();
|
2002-05-30 13:36:32 +00:00
|
|
|
}
|
|
|
|
|
2014-06-18 12:14:29 +02:00
|
|
|
ScViewData& rViewData = pViewShell->GetViewData();
|
2002-05-30 13:36:32 +00:00
|
|
|
SfxItemSet aArgSet( pViewShell->GetPool(),
|
|
|
|
SCITEM_QUERYDATA, SCITEM_QUERYDATA );
|
2014-06-18 12:14:29 +02:00
|
|
|
aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, &rViewData, &aQueryParam ) );
|
2002-05-30 13:36:32 +00:00
|
|
|
|
2004-05-10 15:07:56 +00:00
|
|
|
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
|
2011-05-21 15:04:26 +02:00
|
|
|
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
|
2004-05-10 15:07:56 +00:00
|
|
|
|
2014-05-11 01:36:27 +09:00
|
|
|
boost::scoped_ptr<AbstractScPivotFilterDlg> pDlg(pFact->CreateScPivotFilterDlg(
|
|
|
|
pViewShell->GetDialogParent(), aArgSet, nSrcTab));
|
2011-05-21 15:04:26 +02:00
|
|
|
OSL_ENSURE(pDlg, "Dialog create fail!");
|
2002-05-30 13:36:32 +00:00
|
|
|
|
|
|
|
if( pDlg->Execute() == RET_OK )
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScSheetSourceDesc aNewDesc(rViewData.GetDocument());
|
2002-05-30 13:36:32 +00:00
|
|
|
if( pDesc )
|
|
|
|
aNewDesc = *pDesc;
|
|
|
|
|
|
|
|
const ScQueryItem& rQueryItem = pDlg->GetOutputItem();
|
2011-01-20 20:22:52 -05:00
|
|
|
aNewDesc.SetQueryParam(rQueryItem.GetQueryData());
|
2002-05-30 13:36:32 +00:00
|
|
|
|
|
|
|
ScDPObject aNewObj( *pDPObj );
|
|
|
|
aNewObj.SetSheetDesc( aNewDesc );
|
2014-06-18 12:14:29 +02:00
|
|
|
ScDBDocFunc aFunc( *rViewData.GetDocShell() );
|
2014-01-28 20:00:32 +01:00
|
|
|
aFunc.DataPilotUpdate( pDPObj, &aNewObj, true, false );
|
2014-06-18 12:14:29 +02:00
|
|
|
rViewData.GetView()->CursorPosChanged(); // shells may be switched
|
2002-05-30 13:36:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 23:25:30 +01:00
|
|
|
void ScPivotShell::GetState( SfxItemSet& rSet )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
ScDocShell* pDocSh = pViewShell->GetViewData().GetDocShell();
|
|
|
|
ScDocument& rDoc = pDocSh->GetDocument();
|
|
|
|
bool bDisable = pDocSh->IsReadOnly() || rDoc.GetChangeTrack();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SfxWhichIter aIter(rSet);
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nWhich = aIter.FirstWhich();
|
2000-09-18 16:07:07 +00:00
|
|
|
while (nWhich)
|
|
|
|
{
|
|
|
|
switch (nWhich)
|
|
|
|
{
|
|
|
|
case SID_PIVOT_RECALC:
|
|
|
|
case SID_PIVOT_KILL:
|
2002-05-30 13:36:32 +00:00
|
|
|
{
|
|
|
|
//! move ReadOnly check to idl flags
|
|
|
|
if ( bDisable )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-05-30 13:36:32 +00:00
|
|
|
rSet.DisableItem( nWhich );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-05-30 13:36:32 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_DP_FILTER:
|
|
|
|
{
|
|
|
|
ScDPObject* pDPObj = GetCurrDPObject();
|
|
|
|
if( bDisable || !pDPObj || !pDPObj->IsSheetData() )
|
|
|
|
rSet.DisableItem( nWhich );
|
|
|
|
}
|
|
|
|
break;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
nWhich = aIter.NextWhich();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-30 13:36:32 +00:00
|
|
|
ScDPObject* ScPivotShell::GetCurrDPObject()
|
|
|
|
{
|
2014-06-18 12:14:29 +02:00
|
|
|
const ScViewData& rViewData = pViewShell->GetViewData();
|
2002-05-30 13:36:32 +00:00
|
|
|
return rViewData.GetDocument()->GetDPAtCursor(
|
|
|
|
rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-10-12 15:59:00 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|