summaryrefslogtreecommitdiffstats
path: root/inc/bf_so3/persist.hxx
blob: 3f959fd8f54bdf0421dfa18f10790b26a665b5a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef _PERSIST_HXX
#define _PERSIST_HXX

#include <bf_svtools/bf_solar.h>

#include <tools/pstm.hxx>
#include <tools/time.hxx>
#include <bf_so3/so2ref.hxx>
#include <bf_so3/iface.hxx>

#include "bf_so3/so3dllapi.h"

/*************************************************************************
*************************************************************************/
#ifdef SvStorage
#undef SvStorage
#endif
#ifdef SvStorageRef
#undef SvStorageRef
#endif
#ifdef SvStorageStream
#undef SvStorageStream
#endif
#ifdef SvStorageStreamRef
#undef SvStorageStreamRef
#endif

namespace binfilter {

#ifndef SO2_DECL_SVSTORAGE_DEFINED
#define SO2_DECL_SVSTORAGE_DEFINED
SO2_DECL_REF(SvStorage)
#endif

class  ImpPersistStorage;
class  ImpPersistFile;
class  ImpItemContainer;
class  SvFactory;
class  SvStorage;


    /*************************************************************************
*************************************************************************/

//=========================================================================
class SO3_DLLPUBLIC SvObjectContainer : virtual public SvObject
/*  [Beschreibung]

    Diese Klasse stellt die Schnittstelle zur Verf"ugung, um auf
    Unter-Objekte, Pseudo-Objekte, Bereiche ... zuzugreifen.
    Diese Objekte werden erst auf Anforderung erzeugt. Sie m"ussen
    also nicht beim "offnen des Dokumentes angelegt werden.

*/
{
friend class ImpItemContainer;
friend class SvFactory;
protected:
                    ~SvObjectContainer();
public:
                    SvObjectContainer();
                    SO2_DECL_STANDARD_CLASS_DLL(SvObjectContainer,SOAPP)

};
#ifndef SO2_DECL_SVOBJECTCONTAINER_DEFINED
#define SO2_DECL_SVOBJECTCONTAINER_DEFINED
SO2_DECL_REF(SvObjectContainer)
#endif
SO2_IMPL_REF(SvObjectContainer)

/*************************************************************************
*************************************************************************/
class SvInfoObjectMemberList;
class SvInfoObject;

#ifndef SO2_DECL_SVPERSIST_DEFINED
#define SO2_DECL_SVPERSIST_DEFINED
SO2_DECL_REF(SvPersist)
#endif

#define SVEXT_PERSIST_STREAM "\002OlePres000"

class SO3_DLLPUBLIC SvPersist : public SvObjectContainer
{
friend class SvInfoObject;
friend class ImpPersistStorage;
friend class ImpPersistFile;
friend class ImpItemContainer;
friend class SvFactory;
private:
    BOOL            bIsModified:1,
                    bIsInit:1,
                    bOpSave:1,
                    bOpSaveAs:1,
                    bSaveExtern:1,  // Kein SetClassName
                    bOpHandsOff:1,  // Fuer Debug, ob SaveCompleted korrekt ist
                    bCreateTempStor:1, // TRUE nach InitNew(0)
                    bSaveFailed:1,  // TRUE nach InitNew(0)
                    bEnableSetModified:1,
                    bDummy0:1,
                    bDummy1:1,
                    bIsObjectShell:1;
    USHORT          nModifyCount;
    SvStorageRef    aStorage;
/*  SvAdviseSinkRef aAdvSink;      Benachrichtigung von externen Obj, fuer Modify */
    SvPersist *     pParent;    // fuer hierarchische Persist-Objekte
private:
    SvInfoObjectMemberList * pChildList;
    Time            aModifiedTime;
    String          aFileName;  // nur fuer das IPersistFile-Interface

    SO3_DLLPRIVATE SvInfoObjectMemberList *GetInfoList();
    SO3_DLLPRIVATE void            CountModified( BOOL bDirection );
    SO3_DLLPRIVATE void            dtorClear();
    SO3_DLLPRIVATE SvPersistRef    CreateObjectFromStorage( SvInfoObject*, const SvStorageRef& );
    SO3_DLLPRIVATE BOOL            ImplCopy( SvPersist*, const String&, BOOL );

protected:
    SO3_DLLPRIVATE void            InitMembers( SvStorage * );
                     ~SvPersist();
#ifdef DBG_UTIL
#define ASSERT_INIT()     AssertInit();
    SO3_DLLPRIVATE void            AssertInit() const;
#else
#define ASSERT_INIT()
#endif
    SO3_DLLPRIVATE void         SetSaveFailed( BOOL bFail = TRUE )
                    { bSaveFailed = bFail; }
    SO3_DLLPRIVATE BOOL         GetSaveFailed() const { return bSaveFailed; }

    virtual void    ModifyChanged();

    virtual BOOL    InitNew( SvStorage * );         // Rekursiv
    virtual BOOL    Load( SvStorage * );            // Rekursiv
    virtual BOOL    Save() {return false;}          // Rekursiv
    virtual void    HandsOff();                     // Rekursiv

    SO3_DLLPRIVATE BOOL            DoLoadContent( SvStorage *, BOOL bOwner );
    virtual void    LoadContent( SvStream & rStm, BOOL bOwner );
    virtual void    SaveContent( SvStream & rStm, BOOL bOwner );

    SO3_DLLPRIVATE BOOL         HasStorage() const { return aStorage.Is(); }
public:
                    SvPersist();
                    SO2_DECL_STANDARD_CLASS_DLL(SvPersist,SOAPP)
    SvStorage *     GetStorage() const;
    SvPersist *     GetParent() const { return pParent; }
    void            SetupStorage( SvStorage * pStor ) const;

    virtual void    FillClass( SvGlobalName * pClassName,
                               ULONG * pFormat,
                               String * pAppName,
                               String * pFullTypeName,
                               String * pShortTypeName,
                               long nFileFormat = SOFFICE_FILEFORMAT_CURRENT ) const;

                    // automatische Objektverwaltung um zu speichern
    BOOL            Insert  ( SvInfoObject * pInfoObj );
    BOOL            Move    ( SvInfoObject * pInfoObj, const String & rStorName, BOOL bCopyStorage=FALSE );
    BOOL            Copy    ( const String & rNewObjName, const String & rNewStorName,
                              SvInfoObject * pSrcInfoObj, SvPersist * pSrc );

                    // call DoClose( pEle ) and unload the child
                    // TRUE, element is unloaded. FALSE cannot unload,
                    // Refcount != 0 or modified.
    BOOL            Unload  ( SvInfoObject * pInfoObj );
    BOOL            Unload  ( SvPersist * pEle );

    void            Remove  ( const String & rEleName );
    void            Remove  ( SvPersist * pEle );
    void            Remove  ( SvInfoObject * pInfoObj );
    SvInfoObject *  Find    ( const String & rEleName ) const;
    SvInfoObject *  Find    ( const SvPersist * pEle ) const;
    const SvInfoObjectMemberList * GetObjectList() const
                    { return pChildList; }

                    // altes Interface
    BOOL            HasObject( const String & rObjName );
    SvPersistRef    GetObject( const String & rObjName );
    SvStorageRef    GetObjectStorage( SvInfoObject* pEle );

                    // eigentliche Funktionalitaet
    void            EnableSetModified( BOOL bEnable = TRUE );
    BOOL            IsEnableSetModified() const
                    { return bEnableSetModified; }
    virtual void    SetModified( BOOL = TRUE );
    BOOL            IsModified();                   // Rekursiv

    SvPersistRef    CopyObject( const String& rObjName, const String& rNewName, SvPersist * pSrc );

    virtual BOOL    DoInitNew( SvStorage * );
    const String &  GetFileName() const { return aFileName; }
    void            SetFileName( const String & rFileName )
                    { aFileName = rFileName; }
    virtual BOOL    DoLoad( const String & rFileName, StreamMode,
                            short nStorMode );
    virtual BOOL    DoLoad( SvStorage * );
    BOOL            DoOwnerLoad( SvStorage * );
    virtual void    DoHandsOff();
    void            CleanUp(BOOL bRecurse=FALSE); //Rekursiv

    const Time &    GetModifyTime() const { return aModifiedTime; }
    void            SetModifyTime( const Time & rTime )
                    { aModifiedTime = rTime; }
    BOOL            IsHandsOff() const { return bOpHandsOff; }

    void            SetObjectShell( BOOL bObjSh ) { bIsObjectShell = bObjSh; }
};
SO2_IMPL_REF(SvPersist)

/*************************************************************************
*************************************************************************/

SV_DECL_REF(SvInfoObject)
class SvInfoObject_Impl;
class SO3_DLLPUBLIC SvInfoObject : public SvPersistBase
{
friend class SvPersist;
private:
    SvPersistRef    aObj;
    String          aObjName;           // object and substorage name
    String          aStorName;          // optional real storage name
    SvGlobalName    aSvClassName;       // name of corresponding SV class
    SvInfoObject_Impl* pImp;
    BOOL            bDeleted;

protected:
    SO3_DLLPRIVATE              ~SvInfoObject();
    SO3_DLLPRIVATE virtual void Assign( const SvInfoObject * pObj );
    SO3_DLLPRIVATE void            SetRealStorageName( const String & rName );
    SO3_DLLPRIVATE void            SetStorageName( const String & rName )
                    { aStorName = rName; }
public:
                    SV_DECL_PERSIST1(SvInfoObject,SvPersistBase,1)
                    SvInfoObject();
                    SvInfoObject( SvPersist *, const String & rObjName );
                    SvInfoObject( const String& rObjName,
                                     const SvGlobalName& rClassName );
    SvInfoObjectRef CreateCopy() const;

    virtual void    SetObj( SvPersist * );

    SvObject  *     GetObj() const { return &aObj; }
    SvPersist *     GetPersist() const { return aObj; }

    void            SetObjName( const String & rName )
                    { aObjName = rName; }
    String          GetObjName() const;

                    // GetStorageName() is the same as GetObjName()
    String          GetStorageName() const;

                    // If object is stored elsewhere, the RealStorageName is not empty
    String          GetRealStorageName() const;
    SvGlobalName    GetClassName() const;
    void            SetClassName( const SvGlobalName& rName )
                    { aSvClassName = rName; }
    BOOL            IsDeleted() const
                    { return bDeleted; }
    void            SetDeleted( BOOL bDel=TRUE );
};

SV_IMPL_REF(SvInfoObject)

// Damit die Liste, anders benannt wird
typedef SvPersistBase SuperSvPersistBase;
SV_DECL_REF_LIST_VISIBILITY(SuperSvPersistBase,SuperSvPersistBase*,SO3_DLLPUBLIC)
SV_IMPL_REF_LIST(SuperSvPersistBase,SuperSvPersistBase*)

class SO3_DLLPUBLIC SvPersistBaseMemberList : public SuperSvPersistBaseMemberList
{
public:
    SvPersistBaseMemberList();

    void   WriteObjects( SvPersistStream &, sal_Bool bOnlyStreamedObj = sal_False ) const;
    SO3_DLLPUBLIC friend SvPersistStream& operator << (SvPersistStream &, const SvPersistBaseMemberList &);
    SO3_DLLPUBLIC friend SvPersistStream& operator >> (SvPersistStream &, SvPersistBaseMemberList &);
};

/*************************************************************************/
#define SV_DECL_PERSIST_LIST(ClassName,EntryName)\
class ClassName##MemberList : public SvPersistBaseMemberList\
{\
public:\
    PRV_SV_DECL_MEMBER_LIST(ClassName,EntryName)\
};

SV_DECL_PERSIST_LIST(SvInfoObject,SvInfoObject*)
PRV_SV_IMPL_MEMBER_LIST(SvInfoObject,SvInfoObject*,SvPersistBaseMemberList)
}

#endif // _PERSIST_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */