/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: dptabsrc.cxx,v $ * $Revision: 1.27 $ * * This file is part of OpenOffice.org. * * 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. * * 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). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" // INCLUDE --------------------------------------------------------------- #include #include #include #include #include #include #include #include #include #include "scitems.hxx" #include "document.hxx" #include "docpool.hxx" #include "patattr.hxx" #include "cell.hxx" #include "dptabsrc.hxx" #include "dptabres.hxx" #include "dptabdat.hxx" #include "global.hxx" #include "collect.hxx" #include "datauno.hxx" // ScDataUnoConversion #include "unoguard.hxx" #include "miscuno.hxx" #include "unonames.hxx" #include #include #include #include #include #include #include #include #include #include #include using namespace com::sun::star; using ::std::vector; using ::std::set; using ::std::hash_map; using ::std::hash_set; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Any; using ::com::sun::star::sheet::DataPilotFieldAutoShowInfo; using ::rtl::OUString; // ----------------------------------------------------------------------- #define SC_MINCOUNT_LIMIT 1000000 // ----------------------------------------------------------------------- SC_SIMPLE_SERVICE_INFO( ScDPSource, "ScDPSource", "com.sun.star.sheet.DataPilotSource" ) SC_SIMPLE_SERVICE_INFO( ScDPDimensions, "ScDPDimensions", "com.sun.star.sheet.DataPilotSourceDimensions" ) SC_SIMPLE_SERVICE_INFO( ScDPDimension, "ScDPDimension", "com.sun.star.sheet.DataPilotSourceDimension" ) SC_SIMPLE_SERVICE_INFO( ScDPHierarchies, "ScDPHierarchies", "com.sun.star.sheet.DataPilotSourceHierarcies" ) SC_SIMPLE_SERVICE_INFO( ScDPHierarchy, "ScDPHierarchy", "com.sun.star.sheet.DataPilotSourceHierarcy" ) SC_SIMPLE_SERVICE_INFO( ScDPLevels, "ScDPLevels", "com.sun.star.sheet.DataPilotSourceLevels" ) SC_SIMPLE_SERVICE_INFO( ScDPLevel, "ScDPLevel", "com.sun.star.sheet.DataPilotSourceLevel" ) SC_SIMPLE_SERVICE_INFO( ScDPMembers, "ScDPMembers", "com.sun.star.sheet.DataPilotSourceMembers" ) SC_SIMPLE_SERVICE_INFO( ScDPMember, "ScDPMember", "com.sun.star.sheet.DataPilotSourceMember" ) // ----------------------------------------------------------------------- // property maps for PropertySetInfo // DataDescription / NumberFormat are internal // ----------------------------------------------------------------------- //! move to a header? BOOL lcl_GetBoolFromAny( const uno::Any& aAny ) { if ( aAny.getValueTypeClass() == uno::TypeClass_BOOLEAN ) return *(sal_Bool*)aAny.getValue(); return FALSE; } void lcl_SetBoolInAny( uno::Any& rAny, BOOL bValue ) { rAny.setValue( &bValue, getBooleanCppuType() ); } // ----------------------------------------------------------------------- ScDPSource::ScDPSource( ScDPTableData* pD ) : pData( pD ), pDimensions( NULL ), nColDimCount( 0 ), nRowDimCount( 0 ), nDataDimCount( 0 ), nPageDimCount( 0 ), bColumnGrand( TRUE ), // default is true bRowGrand( TRUE ), bIgnoreEmptyRows( FALSE ), bRepeatIfEmpty( FALSE ), nDupCount( 0 ), pResData( NULL ), pColResRoot( NULL ), pRowResRoot( NULL ), pColResults( NULL ), pRowResults( NULL ), bResultOverflow( FALSE ), mpGrandTotalName(NULL) { pData->SetEmptyFlags( bIgnoreEmptyRows, bRepeatIfEmpty ); } ScDPSource::~ScDPSource() { if (pDimensions) pDimensions->release(); // ref-counted //! free lists delete[] pColResults; delete[] pRowResults; delete pColResRoot; delete pRowResRoot; delete pResData; } void ScDPSource::SetGrandTotalName(const ::rtl::OUString& rName) { mpGrandTotalName.reset(new ::rtl::OUString(rName)); } const ::rtl::OUString* ScDPSource::GetGrandTotalName() const { return mpGrandTotalName.get(); } USHORT ScDPSource::GetOrientation(long nColumn) { long i; for (i=0; i= nDataDimCount) return NULL; long nDimIndex = nDataDims[nIndex]; return GetDimensionsObject()->getByIndex(nDimIndex); } String ScDPSource::GetDataDimName( long nIndex ) { String aRet; ScDPDimension* pDim = GetDataDimension(nIndex); if (pDim) aRet = String(pDim->getName()); return aRet; } long ScDPSource::GetPosition(long nColumn) { long i; for (i=0; iIsDataLayoutDimension(nColumn) ) rAllowed = FALSE; else { // no subtotals if no other dim but data layout follows long nNextIndex = i+1; if ( nNextIndex < nCount && pSource->IsDataLayoutDimension(pArray[nNextIndex]) ) ++nNextIndex; if ( nNextIndex >= nCount ) rAllowed = FALSE; } return TRUE; // found } return FALSE; } BOOL ScDPSource::SubTotalAllowed(long nColumn) { //! cache this at ScDPResultData BOOL bAllowed = TRUE; if ( lcl_TestSubTotal( bAllowed, nColumn, nColDims, nColDimCount, this ) ) return bAllowed; if ( lcl_TestSubTotal( bAllowed, nColumn, nRowDims, nRowDimCount, this ) ) return bAllowed; return bAllowed; } void lcl_RemoveDim( long nRemove, long* pDims, long& rCount ) { for (long i=0; i