office-gobmx/sc/inc/dpsave.hxx

350 lines
12 KiB
C++
Raw Normal View History

2010-10-27 06:43:08 -05:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 11:07:07 -05:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 11:07:07 -05:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 11:07:07 -05:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 11:07:07 -05:00
*
* This file is part of OpenOffice.org.
2000-09-18 11:07:07 -05: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 11:07:07 -05: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 11:07:07 -05: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 11:07:07 -05:00
*
************************************************************************/
#ifndef SC_DPSAVE_HXX
#define SC_DPSAVE_HXX
#include <sal/types.h>
2000-09-18 11:07:07 -05:00
#include <tools/string.hxx>
#include <tools/list.hxx>
#include <com/sun/star/sheet/XDimensionsSupplier.hpp>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include "scdllapi.h"
#include <hash_map>
#include <list>
#include <memory>
namespace com { namespace sun { namespace star { namespace sheet {
struct DataPilotFieldReference;
struct DataPilotFieldSortInfo;
struct DataPilotFieldAutoShowInfo;
struct DataPilotFieldLayoutInfo;
} } } }
class ScDPDimensionSaveData;
class ScDPTableData;
2000-09-18 11:07:07 -05:00
// --------------------------------------------------------------------
//
2011-01-31 13:30:59 -06:00
// classes to save Data Pilot settings
2000-09-18 11:07:07 -05:00
//
class ScDPSaveMember
{
private:
2011-01-31 13:30:59 -06:00
String aName;
::std::auto_ptr<rtl::OUString> mpLayoutName; // custom name to be displayed in the table.
2011-01-31 13:30:59 -06:00
sal_uInt16 nVisibleMode;
sal_uInt16 nShowDetailsMode;
2000-09-18 11:07:07 -05:00
public:
2011-01-31 13:30:59 -06:00
ScDPSaveMember(const String& rName);
ScDPSaveMember(const ScDPSaveMember& r);
~ScDPSaveMember();
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
bool operator== ( const ScDPSaveMember& r ) const;
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
const String& GetName() const
{ return aName; }
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
bool HasIsVisible() const;
SC_DLLPUBLIC void SetIsVisible(bool bSet);
bool GetIsVisible() const
{ return bool(nVisibleMode); }
2011-01-31 13:30:59 -06:00
bool HasShowDetails() const;
SC_DLLPUBLIC void SetShowDetails(bool bSet);
bool GetShowDetails() const
{ return bool(nShowDetailsMode); }
void SetName( const String& rNew ); // used if the source member was renamed (groups)
SC_DLLPUBLIC void SetLayoutName( const ::rtl::OUString& rName );
SC_DLLPUBLIC const ::rtl::OUString* GetLayoutName() const;
2011-01-31 13:30:59 -06:00
void RemoveLayoutName();
2011-01-31 13:30:59 -06:00
void WriteToSource( const com::sun::star::uno::Reference<com::sun::star::uno::XInterface>& xMember,
sal_Int32 nPosition );
2000-09-18 11:07:07 -05:00
};
bool operator == (const ::com::sun::star::sheet::DataPilotFieldSortInfo &l, const ::com::sun::star::sheet::DataPilotFieldSortInfo &r );
bool operator == (const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo &l, const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo &r );
bool operator == (const ::com::sun::star::sheet::DataPilotFieldReference &l, const ::com::sun::star::sheet::DataPilotFieldReference &r );
2011-01-31 13:30:59 -06:00
class SC_DLLPUBLIC ScDPSaveDimension
2000-09-18 11:07:07 -05:00
{
private:
2011-01-31 13:30:59 -06:00
String aName;
String* pSelectedPage;
::std::auto_ptr<rtl::OUString> mpLayoutName;
::std::auto_ptr<rtl::OUString> mpSubtotalName;
2011-01-31 13:30:59 -06:00
bool bIsDataLayout;
bool bDupFlag;
sal_uInt16 nOrientation;
sal_uInt16 nFunction; // enum GeneralFunction, for data dimensions
long nUsedHierarchy;
sal_uInt16 nShowEmptyMode; //! at level
bool bSubTotalDefault; //! at level
long nSubTotalCount;
sal_uInt16* pSubTotalFuncs; // enum GeneralFunction
::com::sun::star::sheet::DataPilotFieldReference* pReferenceValue;
2011-01-31 13:30:59 -06:00
::com::sun::star::sheet::DataPilotFieldSortInfo* pSortInfo; // (level)
::com::sun::star::sheet::DataPilotFieldAutoShowInfo* pAutoShowInfo; // (level)
::com::sun::star::sheet::DataPilotFieldLayoutInfo* pLayoutInfo; // (level)
2000-09-18 11:07:07 -05:00
public:
typedef std::hash_map <String, ScDPSaveMember*, rtl::OUStringHash> MemberHash;
2011-01-31 13:30:59 -06:00
typedef std::list <ScDPSaveMember*> MemberList;
private:
MemberHash maMemberHash;
MemberList maMemberList;
2011-01-31 13:30:59 -06:00
2000-09-18 11:07:07 -05:00
public:
2011-01-31 13:30:59 -06:00
ScDPSaveDimension(const String& rName, bool bDataLayout);
ScDPSaveDimension(const ScDPSaveDimension& r);
~ScDPSaveDimension();
bool operator== ( const ScDPSaveDimension& r ) const;
const MemberList& GetMembers() const
{ return maMemberList; }
void AddMember(ScDPSaveMember* pMember);
void SetDupFlag(bool bSet)
{ bDupFlag = bSet; }
bool GetDupFlag() const
{ return bDupFlag; }
const String& GetName() const
{ return aName; }
bool IsDataLayout() const
{ return bIsDataLayout; }
void SetName( const String& rNew ); // used if the source dim was renamed (groups)
void SetOrientation(sal_uInt16 nNew);
void SetSubTotals(long nCount, const sal_uInt16* pFuncs);
long GetSubTotalsCount() const
{ return nSubTotalCount; }
sal_uInt16 GetSubTotalFunc(long nIndex) const
{ return pSubTotalFuncs[nIndex]; }
bool HasShowEmpty() const;
void SetShowEmpty(bool bSet);
bool GetShowEmpty() const
{ return bool(nShowEmptyMode); }
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
void SetFunction(sal_uInt16 nNew); // enum GeneralFunction
sal_uInt16 GetFunction() const
{ return nFunction; }
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
void SetUsedHierarchy(long nNew);
long GetUsedHierarchy() const
{ return nUsedHierarchy; }
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
void SetLayoutName(const ::rtl::OUString& rName);
const ::rtl::OUString* GetLayoutName() const;
void RemoveLayoutName();
void SetSubtotalName(const ::rtl::OUString& rName);
const ::rtl::OUString* GetSubtotalName() const;
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
bool IsMemberNameInUse(const ::rtl::OUString& rName) const;
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
const ::com::sun::star::sheet::DataPilotFieldReference* GetReferenceValue() const
{ return pReferenceValue; }
2011-01-31 13:30:59 -06:00
void SetReferenceValue(const ::com::sun::star::sheet::DataPilotFieldReference* pNew);
2011-01-31 13:30:59 -06:00
const ::com::sun::star::sheet::DataPilotFieldSortInfo* GetSortInfo() const
{ return pSortInfo; }
2011-01-31 13:30:59 -06:00
void SetSortInfo(const ::com::sun::star::sheet::DataPilotFieldSortInfo* pNew);
const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* GetAutoShowInfo() const
{ return pAutoShowInfo; }
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
void SetAutoShowInfo(const ::com::sun::star::sheet::DataPilotFieldAutoShowInfo* pNew);
const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* GetLayoutInfo() const
{ return pLayoutInfo; }
2011-01-31 13:30:59 -06:00
void SetLayoutInfo(const ::com::sun::star::sheet::DataPilotFieldLayoutInfo* pNew);
2011-01-31 13:30:59 -06:00
void SetCurrentPage( const String* pPage ); // NULL = no selection (all)
bool HasCurrentPage() const;
const String& GetCurrentPage() const;
2011-01-31 13:30:59 -06:00
sal_uInt16 GetOrientation() const
{ return nOrientation; }
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
ScDPSaveMember* GetExistingMemberByName(const String& rName);
/**
* Get a member object by its name. If one doesn't exist, creat a new
* object and return it. This class manages the life cycle of all member
* objects belonging to it, so <i>don't delete the returned instance.</i>
*
* @param rName member name
*
* @return pointer to the member object.
*/
2011-01-31 13:30:59 -06:00
ScDPSaveMember* GetMemberByName(const String& rName);
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
void SetMemberPosition( const String& rName, sal_Int32 nNewPos );
2011-01-31 13:30:59 -06:00
void WriteToSource( const com::sun::star::uno::Reference<com::sun::star::uno::XInterface>& xDim );
void Refresh( const com::sun::star::uno::Reference<com::sun::star::sheet::XDimensionsSupplier>& xSource ,
const std::list<String> & deletedDims);
2011-01-31 13:30:59 -06:00
void UpdateMemberVisibility(const ::std::hash_map< ::rtl::OUString, bool, ::rtl::OUStringHash>& rData);
2011-01-31 13:30:59 -06:00
bool HasInvisibleMember() const;
2000-09-18 11:07:07 -05:00
};
class ScDPSaveData
{
private:
2011-01-31 13:30:59 -06:00
List aDimList;
ScDPDimensionSaveData* pDimensionData; // settings that create new dimensions
sal_uInt16 nColumnGrandMode;
sal_uInt16 nRowGrandMode;
sal_uInt16 nIgnoreEmptyMode;
sal_uInt16 nRepeatEmptyMode;
bool bFilterButton; // not passed to DataPilotSource
bool bDrillDown; // not passed to DataPilotSource
long mnCacheId;
2000-09-18 11:07:07 -05:00
/** if true, all dimensions already have all of their member instances
* created. */
2011-01-31 13:30:59 -06:00
bool mbDimensionMembersBuilt;
::std::auto_ptr<rtl::OUString> mpGrandTotalName;
2000-09-18 11:07:07 -05:00
public:
2011-01-31 13:30:59 -06:00
SC_DLLPUBLIC ScDPSaveData();
ScDPSaveData(const ScDPSaveData& r);
SC_DLLPUBLIC ~ScDPSaveData();
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
ScDPSaveData& operator= ( const ScDPSaveData& r );
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
bool operator== ( const ScDPSaveData& r ) const;
2000-09-18 11:07:07 -05:00
2011-01-31 13:30:59 -06:00
SC_DLLPUBLIC void SetGrandTotalName(const ::rtl::OUString& rName);
SC_DLLPUBLIC const ::rtl::OUString* GetGrandTotalName() const;
2011-01-31 13:30:59 -06:00
const List& GetDimensions() const
{ return aDimList; }
void AddDimension(ScDPSaveDimension* pDim)
{ aDimList.Insert(pDim, LIST_APPEND); }
2000-09-18 11:07:07 -05:00
/**
* Get a dimension object by its name. <i>If one doesn't exist for the
* given name, it creats a new one.</i>
*
* @param rName dimension name
*
* @return pointer to the dimension object. The ScDPSaveData instance
* manages its life cycle; hence the caller must
* <i>not</i> delete this object.
*/
2011-01-31 13:30:59 -06:00
ScDPSaveDimension* GetDimensionByName(const String& rName);
SC_DLLPUBLIC ScDPSaveDimension* GetDataLayoutDimension();
SC_DLLPUBLIC ScDPSaveDimension* GetExistingDataLayoutDimension() const;
ScDPSaveDimension* DuplicateDimension(const String& rName);
SC_DLLPUBLIC ScDPSaveDimension& DuplicateDimension(const ScDPSaveDimension& rDim);
SC_DLLPUBLIC ScDPSaveDimension* GetExistingDimensionByName(const String& rName) const;
SC_DLLPUBLIC ScDPSaveDimension* GetNewDimensionByName(const String& rName);
void RemoveDimensionByName(const String& rName);
ScDPSaveDimension* GetInnermostDimension(sal_uInt16 nOrientation);
ScDPSaveDimension* GetFirstDimension(::com::sun::star::sheet::DataPilotFieldOrientation eOrientation);
long GetDataDimensionCount() const;
void SetPosition( ScDPSaveDimension* pDim, long nNew );
SC_DLLPUBLIC void SetColumnGrand( bool bSet );
bool GetColumnGrand() const
{ return bool(nColumnGrandMode); }
SC_DLLPUBLIC void SetRowGrand( bool bSet );
bool GetRowGrand() const
{ return bool(nRowGrandMode); }
void SetIgnoreEmptyRows( bool bSet );
bool GetIgnoreEmptyRows() const
{ return bool(nIgnoreEmptyMode); }
void SetRepeatIfEmpty( bool bSet );
bool GetRepeatIfEmpty() const
{ return bool(nRepeatEmptyMode); }
SC_DLLPUBLIC void SetFilterButton( bool bSet );
bool GetFilterButton() const
{ return bFilterButton; }
SC_DLLPUBLIC void SetDrillDown( bool bSet );
bool GetDrillDown() const
{ return bDrillDown; }
void WriteToSource( const com::sun::star::uno::Reference<com::sun::star::sheet::XDimensionsSupplier>& xSource );
void Refresh( const com::sun::star::uno::Reference<com::sun::star::sheet::XDimensionsSupplier>& xSource );
bool IsEmpty() const;
inline long GetCacheId() const
{ return mnCacheId; }
inline void SetCacheId( long nCacheId )
{ mnCacheId = nCacheId; }
const ScDPDimensionSaveData* GetExistingDimensionData() const
{ return pDimensionData; }
SC_DLLPUBLIC ScDPDimensionSaveData* GetDimensionData(); // create if not there
void SetDimensionData( const ScDPDimensionSaveData* pNew ); // copied
void BuildAllDimensionMembers(ScDPTableData* pData);
/**
* Check whether a dimension has one or more invisible members.
*
* @param rDimName dimension name
*/
2011-01-31 13:30:59 -06:00
SC_DLLPUBLIC bool HasInvisibleMember(const ::rtl::OUString& rDimName) const;
2000-09-18 11:07:07 -05:00
};
#endif
2010-10-27 06:43:08 -05:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */