1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dpobject.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_DPOBJECT_HXX
32 #define SC_DPOBJECT_HXX
38 #ifndef SC_COLLECT_HXX
39 #include "collect.hxx"
42 #ifndef _COM_SUN_STAR_SHEET_XDIMENSIONSSUPPLIER_HPP_
43 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
50 //------------------------------------------------------------------
55 struct ScDPPositionData
;
56 class ScMultipleReadHeader
;
57 class ScMultipleWriteHeader
;
59 class ScPivotCollection
;
61 struct ScImportSourceDesc
;
62 struct ScSheetSourceDesc
;
65 struct ScDPServiceDesc
73 ScDPServiceDesc( const String
& rServ
, const String
& rSrc
, const String
& rNam
,
74 const String
& rUser
, const String
& rPass
) :
75 aServiceName( rServ
), aParSource( rSrc
), aParName( rNam
),
76 aParUser( rUser
), aParPass( rPass
) { }
78 BOOL
operator== ( const ScDPServiceDesc
& rOther
) const
79 { return aServiceName
== rOther
.aServiceName
&&
80 aParSource
== rOther
.aParSource
&&
81 aParName
== rOther
.aParName
&&
82 aParUser
== rOther
.aParUser
&&
83 aParPass
== rOther
.aParPass
; }
87 class ScDPObject
: public DataObject
92 ScDPSaveData
* pSaveData
;
96 ScSheetSourceDesc
* pSheetDesc
; // for sheet data
97 ScImportSourceDesc
* pImpDesc
; // for database data
98 ScDPServiceDesc
* pServDesc
; // for external service
100 ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XDimensionsSupplier
> xSource
;
102 BOOL bSettingsChanged
;
103 BOOL bAlive
; // FALSE if only used to hold settings
106 void CreateObjects();
109 ScDPObject( ScDocument
* pD
);
110 ScDPObject(const ScDPObject
& r
);
111 virtual ~ScDPObject();
113 virtual DataObject
* Clone() const;
115 void SetAlive(BOOL bSet
);
117 void InvalidateData();
118 void InvalidateSource();
121 void SetSaveData(const ScDPSaveData
& rData
);
122 ScDPSaveData
* GetSaveData() const { return pSaveData
; }
124 void SetOutRange(const ScRange
& rRange
);
125 const ScRange
& GetOutRange() const { return aOutRange
; }
127 void SetSheetDesc(const ScSheetSourceDesc
& rDesc
);
128 void SetImportDesc(const ScImportSourceDesc
& rDesc
);
129 void SetServiceData(const ScDPServiceDesc
& rDesc
);
132 const ScSheetSourceDesc
* GetSheetDesc() const { return pSheetDesc
; }
133 const ScImportSourceDesc
* GetImportSourceDesc() const { return pImpDesc
; }
134 const ScDPServiceDesc
* GetDPServiceDesc() const { return pServDesc
; }
137 BOOL
IsSheetData() const;
138 BOOL
IsImportData() const { return(pImpDesc
!= NULL
); }
139 BOOL
IsServiceData() const { return(pServDesc
!= NULL
); }
141 void SetName(const String
& rNew
);
142 const String
& GetName() const { return aTableName
; }
143 void SetTag(const String
& rNew
);
144 const String
& GetTag() const { return aTableTag
; }
148 BOOL
StoreOld(SvStream
& rStream
, ScMultipleWriteHeader
& rHdr
) const;
149 BOOL
StoreNew(SvStream
& rStream
, ScMultipleWriteHeader
& rHdr
) const;
150 BOOL
LoadNew(SvStream
& rStream
, ScMultipleReadHeader
& rHdr
);
151 BOOL
FillOldParam(ScPivotParam
& rParam
, BOOL bForFile
) const;
152 void InitFromOldPivot(const ScPivot
& rOld
, ScDocument
* pDoc
, BOOL bSetSource
);
154 void UpdateReference( UpdateRefMode eUpdateRefMode
,
155 const ScRange
& r
, short nDx
, short nDy
, short nDz
);
157 static void ConvertOrientation( ScDPSaveData
& rSaveData
,
158 PivotField
* pFields
, USHORT nCount
, USHORT nOrient
,
159 ScDocument
* pDoc
, USHORT nRow
, USHORT nTab
,
160 const ::com::sun::star::uno::Reference
<
161 ::com::sun::star::sheet::XDimensionsSupplier
>& xSource
,
163 PivotField
* pRefColFields
= NULL
, USHORT nRefColCount
= 0,
164 PivotField
* pRefRowFields
= NULL
, USHORT nRefRowCount
= 0 );
168 class ScDPCollection
: public Collection
174 ScDPCollection(ScDocument
* pDocument
);
175 ScDPCollection(const ScDPCollection
& r
);
176 virtual ~ScDPCollection();
178 virtual DataObject
* Clone() const;
180 ScDPObject
* operator[](USHORT nIndex
) const {return (ScDPObject
*)At(nIndex
);}
182 BOOL
StoreOld( SvStream
& rStream
) const;
183 BOOL
StoreNew( SvStream
& rStream
) const;
184 BOOL
LoadNew( SvStream
& rStream
);
186 void ConvertOldTables( ScPivotCollection
& rOldColl
);
188 void UpdateReference( UpdateRefMode eUpdateRefMode
,
189 const ScRange
& r
, short nDx
, short nDy
, short nDz
);
191 String
CreateNewName( USHORT nMin
= 1 ) const;
196 } //namespace binfilter