2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 00:35:36 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:35:36 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:35:36 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:35:36 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:35:36 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:35:36 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-07-21 14:06:26 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sc.hxx"
|
|
|
|
|
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>
|
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"
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
TYPEINIT1( ScPivotShell, SfxShell );
|
|
|
|
|
|
|
|
SFX_IMPL_INTERFACE(ScPivotShell, SfxShell, ScResId(SCSTR_PIVOTSHELL))
|
|
|
|
{
|
|
|
|
SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_PIVOT) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScPivotShell::ScPivotShell( ScTabViewShell* pViewSh ) :
|
|
|
|
SfxShell(pViewSh),
|
|
|
|
pViewShell( pViewSh )
|
|
|
|
{
|
|
|
|
SetPool( &pViewSh->GetPool() );
|
2008-01-10 12:20:46 +00:00
|
|
|
ScViewData* pViewData = pViewSh->GetViewData();
|
|
|
|
SfxUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
|
|
|
|
SetUndoManager( pMgr );
|
|
|
|
if ( !pViewData->GetDocument()->IsUndoEnabled() )
|
|
|
|
{
|
|
|
|
pMgr->SetMaxUndoActionCount( 0 );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
SetHelpId( HID_SCSHELL_PIVOTSH );
|
|
|
|
SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Pivot")));
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
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();
|
|
|
|
DBG_ASSERT( pDesc, "no sheet source for DP filter dialog" );
|
|
|
|
if( pDesc )
|
|
|
|
{
|
|
|
|
aQueryParam = pDesc->aQueryParam;
|
|
|
|
nSrcTab = pDesc->aSourceRange.aStart.Tab();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScViewData* pViewData = pViewShell->GetViewData();
|
|
|
|
SfxItemSet aArgSet( pViewShell->GetPool(),
|
|
|
|
SCITEM_QUERYDATA, SCITEM_QUERYDATA );
|
|
|
|
aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, pViewData, &aQueryParam ) );
|
|
|
|
|
2004-05-10 15:07:56 +00:00
|
|
|
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
|
2010-10-01 17:50:24 +13:00
|
|
|
DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
|
2004-05-10 15:07:56 +00:00
|
|
|
|
|
|
|
AbstractScPivotFilterDlg* pDlg = pFact->CreateScPivotFilterDlg( pViewShell->GetDialogParent(),
|
|
|
|
aArgSet, nSrcTab,
|
2007-04-26 08:57:21 +00:00
|
|
|
RID_SCDLG_PIVOTFILTER);
|
2010-10-01 17:50:24 +13:00
|
|
|
DBG_ASSERT(pDlg, "Dialog create fail!");
|
2002-05-30 13:36:32 +00:00
|
|
|
|
|
|
|
if( pDlg->Execute() == RET_OK )
|
|
|
|
{
|
|
|
|
ScSheetSourceDesc aNewDesc;
|
|
|
|
if( pDesc )
|
|
|
|
aNewDesc = *pDesc;
|
|
|
|
|
|
|
|
const ScQueryItem& rQueryItem = pDlg->GetOutputItem();
|
|
|
|
aNewDesc.aQueryParam = rQueryItem.GetQueryData();
|
|
|
|
|
|
|
|
ScDPObject aNewObj( *pDPObj );
|
|
|
|
aNewObj.SetSheetDesc( aNewDesc );
|
|
|
|
ScDBDocFunc aFunc( *pViewData->GetDocShell() );
|
|
|
|
aFunc.DataPilotUpdate( pDPObj, &aNewObj, TRUE, FALSE );
|
|
|
|
pViewData->GetView()->CursorPosChanged(); // shells may be switched
|
|
|
|
}
|
|
|
|
delete pDlg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = pViewShell->GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2002-05-30 13:36:32 +00:00
|
|
|
BOOL bDisable = pDocSh->IsReadOnly() || pDoc->GetChangeTrack();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SfxWhichIter aIter(rSet);
|
|
|
|
USHORT nWhich = aIter.FirstWhich();
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
const ScViewData& rViewData = *pViewShell->GetViewData();
|
|
|
|
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: */
|