sync master with lastest vba changes
[ooovba.git] / binfilter / inc / bf_so3 / persist.hxx
blob2db1b96d62b51e27e062e07c18d686843c829814
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: persist.hxx,v $
10 * $Revision: 1.5 $
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 _PERSIST_HXX
32 #define _PERSIST_HXX
34 #ifndef _TIME_HXX //autogen
35 #include <tools/time.hxx>
36 #endif
37 #include <bf_so3/so2ref.hxx>
38 #include <bf_so3/iface.hxx>
40 #ifndef INCLUDED_SO3DLLAPI_H
41 #include "bf_so3/so3dllapi.h"
42 #endif
44 /*************************************************************************
45 *************************************************************************/
46 #ifdef SvStorage
47 #undef SvStorage
48 #endif
49 #ifdef SvStorageRef
50 #undef SvStorageRef
51 #endif
52 #ifdef SvStorageStream
53 #undef SvStorageStream
54 #endif
55 #ifdef SvStorageStreamRef
56 #undef SvStorageStreamRef
57 #endif
59 namespace binfilter {
61 #ifndef SO2_DECL_SVSTORAGE_DEFINED
62 #define SO2_DECL_SVSTORAGE_DEFINED
63 SO2_DECL_REF(SvStorage)
64 #endif
66 class ImpPersistStorage;
67 class ImpPersistFile;
68 class ImpItemContainer;
69 class SvFactory;
70 class SvStorage;
73 /*************************************************************************
74 *************************************************************************/
76 //=========================================================================
77 class SO3_DLLPUBLIC SvObjectContainer : virtual public SvObject
78 /* [Beschreibung]
80 Diese Klasse stellt die Schnittstelle zur Verf"ugung, um auf
81 Unter-Objekte, Pseudo-Objekte, Bereiche ... zuzugreifen.
82 Diese Objekte werden erst auf Anforderung erzeugt. Sie m"ussen
83 also nicht beim "offnen des Dokumentes angelegt werden.
87 friend class ImpItemContainer;
88 friend class SvFactory;
89 protected:
90 ~SvObjectContainer();
91 public:
92 SvObjectContainer();
93 SO2_DECL_STANDARD_CLASS_DLL(SvObjectContainer,SOAPP)
96 #ifndef SO2_DECL_SVOBJECTCONTAINER_DEFINED
97 #define SO2_DECL_SVOBJECTCONTAINER_DEFINED
98 SO2_DECL_REF(SvObjectContainer)
99 #endif
100 SO2_IMPL_REF(SvObjectContainer)
102 /*************************************************************************
103 *************************************************************************/
104 class SvInfoObjectMemberList;
105 class SvInfoObject;
107 #ifndef SO2_DECL_SVPERSIST_DEFINED
108 #define SO2_DECL_SVPERSIST_DEFINED
109 SO2_DECL_REF(SvPersist)
110 #endif
112 #define SVEXT_PERSIST_STREAM "\002OlePres000"
114 class SO3_DLLPUBLIC SvPersist : public SvObjectContainer
116 friend class SvInfoObject;
117 friend class ImpPersistStorage;
118 friend class ImpPersistFile;
119 friend class ImpItemContainer;
120 friend class SvFactory;
121 private:
122 BOOL bIsModified:1,
123 bIsInit:1,
124 bOpSave:1,
125 bOpSaveAs:1,
126 bSaveExtern:1, // Kein SetClassName
127 bOpHandsOff:1, // Fuer Debug, ob SaveCompleted korrekt ist
128 bCreateTempStor:1, // TRUE nach InitNew(0)
129 bSaveFailed:1, // TRUE nach InitNew(0)
130 bEnableSetModified:1,
131 bDummy0:1,
132 bDummy1:1,
133 bIsObjectShell:1;
134 USHORT nModifyCount;
135 SvStorageRef aStorage;
136 /* SvAdviseSinkRef aAdvSink; Benachrichtigung von externen Obj, fuer Modify */
137 SvPersist * pParent; // fuer hierarchische Persist-Objekte
138 private:
139 SvInfoObjectMemberList * pChildList;
140 Time aModifiedTime;
141 String aFileName; // nur fuer das IPersistFile-Interface
143 SO3_DLLPRIVATE SvInfoObjectMemberList *GetInfoList();
144 SO3_DLLPRIVATE void CountModified( BOOL bDirection );
145 SO3_DLLPRIVATE void dtorClear();
146 SO3_DLLPRIVATE BOOL SaveElement( SvStorage*, SvInfoObject* );
147 SO3_DLLPRIVATE SvPersistRef CreateObjectFromStorage( SvInfoObject*, const SvStorageRef& );
148 SO3_DLLPRIVATE BOOL ImplCopy( SvPersist*, const String&, BOOL );
150 protected:
151 SO3_DLLPRIVATE void InitMembers( SvStorage * );
152 ~SvPersist();
153 #ifdef DBG_UTIL
154 #define ASSERT_INIT() AssertInit();
155 SO3_DLLPRIVATE void AssertInit() const;
156 #else
157 #define ASSERT_INIT()
158 #endif
159 SO3_DLLPRIVATE void SetSaveFailed( BOOL bFail = TRUE )
160 { bSaveFailed = bFail; }
161 SO3_DLLPRIVATE BOOL GetSaveFailed() const { return bSaveFailed; }
163 virtual void ModifyChanged();
165 virtual BOOL InitNew( SvStorage * ); // Rekursiv
166 virtual BOOL Load( SvStorage * ); // Rekursiv
167 virtual BOOL Save(); // Rekursiv
168 virtual BOOL SaveAs( SvStorage * pNewStg ); // Rekursiv
169 virtual void HandsOff(); // Rekursiv
170 virtual BOOL SaveCompleted( SvStorage * ); // Rekursiv
172 SO3_DLLPRIVATE BOOL DoLoadContent( SvStorage *, BOOL bOwner );
173 virtual void LoadContent( SvStream & rStm, BOOL bOwner );
174 SO3_DLLPRIVATE BOOL DoSaveContent( SvStorage *, BOOL bOwner );
175 virtual void SaveContent( SvStream & rStm, BOOL bOwner );
177 BOOL SaveChilds(); // Rekursiv
178 BOOL SaveAsChilds( SvStorage * pNewStg );// Rekursiv
179 BOOL SaveCompletedChilds( SvStorage * ); // Rekursiv
180 SO3_DLLPRIVATE BOOL HasStorage() const { return aStorage.Is(); }
181 public:
182 SvPersist();
183 SO2_DECL_STANDARD_CLASS_DLL(SvPersist,SOAPP)
184 SvStorage * GetStorage() const;
185 SvPersist * GetParent() const { return pParent; }
186 void SetupStorage( SvStorage * pStor ) const;
188 virtual void FillClass( SvGlobalName * pClassName,
189 ULONG * pFormat,
190 String * pAppName,
191 String * pFullTypeName,
192 String * pShortTypeName,
193 long nFileFormat = SOFFICE_FILEFORMAT_CURRENT ) const;
195 // automatische Objektverwaltung um zu speichern
196 BOOL Insert ( SvInfoObject * pInfoObj );
197 BOOL Move ( SvInfoObject * pInfoObj, const String & rStorName, BOOL bCopyStorage=FALSE );
198 BOOL Copy ( const String & rNewObjName, const String & rNewStorName,
199 SvInfoObject * pSrcInfoObj, SvPersist * pSrc );
201 // call DoClose( pEle ) and unload the child
202 // TRUE, element is unloaded. FALSE cannot unload,
203 // Refcount != 0 or modified.
204 BOOL Unload ( SvInfoObject * pInfoObj );
205 BOOL Unload ( SvPersist * pEle );
207 void Remove ( const String & rEleName );
208 void Remove ( SvPersist * pEle );
209 void Remove ( SvInfoObject * pInfoObj );
210 SvInfoObject * Find ( const String & rEleName ) const;
211 SvInfoObject * Find ( const SvPersist * pEle ) const;
212 const SvInfoObjectMemberList * GetObjectList() const
213 { return pChildList; }
215 // altes Interface
216 BOOL HasObject( const String & rObjName );
217 SvPersistRef GetObject( const String & rObjName );
218 SvStorageRef GetObjectStorage( SvInfoObject* pEle );
220 // eigentliche Funktionalitaet
221 void EnableSetModified( BOOL bEnable = TRUE );
222 BOOL IsEnableSetModified() const
223 { return bEnableSetModified; }
224 virtual void SetModified( BOOL = TRUE );
225 BOOL IsModified(); // Rekursiv
227 SvPersistRef CopyObject( const String& rObjName, const String& rNewName, SvPersist * pSrc );
229 virtual BOOL DoInitNew( SvStorage * );
230 const String & GetFileName() const { return aFileName; }
231 void SetFileName( const String & rFileName )
232 { aFileName = rFileName; }
233 virtual BOOL DoLoad( const String & rFileName, StreamMode,
234 short nStorMode );
235 virtual BOOL DoLoad( SvStorage * );
236 BOOL DoOwnerLoad( SvStorage * );
237 virtual BOOL DoSave();
238 virtual BOOL DoSaveAs( SvStorage * pNewStg );
239 virtual void DoHandsOff();
240 virtual BOOL DoSaveCompleted( SvStorage * = NULL );
241 void CleanUp(BOOL bRecurse=FALSE); //Rekursiv
243 const Time & GetModifyTime() const { return aModifiedTime; }
244 void SetModifyTime( const Time & rTime )
245 { aModifiedTime = rTime; }
246 BOOL IsHandsOff() const { return bOpHandsOff; }
248 void SetObjectShell( BOOL bObjSh ) { bIsObjectShell = bObjSh; }
250 SO2_IMPL_REF(SvPersist)
252 /*************************************************************************
253 *************************************************************************/
255 SV_DECL_REF(SvInfoObject)
256 class SvInfoObject_Impl;
257 class SO3_DLLPUBLIC SvInfoObject : public SvPersistBase
259 friend class SvPersist;
260 private:
261 SvPersistRef aObj;
262 String aObjName; // object and substorage name
263 String aStorName; // optional real storage name
264 SvGlobalName aSvClassName; // name of corresponding SV class
265 SvInfoObject_Impl* pImp;
266 BOOL bDeleted;
268 protected:
269 SO3_DLLPRIVATE ~SvInfoObject();
270 SO3_DLLPRIVATE virtual void Assign( const SvInfoObject * pObj );
271 SO3_DLLPRIVATE void SetRealStorageName( const String & rName );
272 SO3_DLLPRIVATE void SetStorageName( const String & rName )
273 { aStorName = rName; }
274 public:
275 SV_DECL_PERSIST1(SvInfoObject,SvPersistBase,1)
276 SvInfoObject();
277 SvInfoObject( SvPersist *, const String & rObjName );
278 SvInfoObject( const String& rObjName,
279 const SvGlobalName& rClassName );
280 SvInfoObjectRef CreateCopy() const;
282 virtual void SetObj( SvPersist * );
284 SvObject * GetObj() const { return &aObj; }
285 SvPersist * GetPersist() const { return aObj; }
287 void SetObjName( const String & rName )
288 { aObjName = rName; }
289 String GetObjName() const;
291 // GetStorageName() is the same as GetObjName()
292 String GetStorageName() const;
294 // If object is stored elsewhere, the RealStorageName is not empty
295 String GetRealStorageName() const;
296 SvGlobalName GetClassName() const;
297 void SetClassName( const SvGlobalName& rName )
298 { aSvClassName = rName; }
299 BOOL IsDeleted() const
300 { return bDeleted; }
301 void SetDeleted( BOOL bDel=TRUE );
304 SV_IMPL_REF(SvInfoObject)
305 SV_DECL_IMPL_PERSIST_LIST(SvInfoObject,SvInfoObject*)
309 #endif // _PERSIST_HXX