update dev300-m58
[ooovba.git] / sot / source / sdstor / stgdir.hxx
blob3e67cb118893f15fbed0987c68f1c814092e5555
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: stgdir.hxx,v $
10 * $Revision: 1.4 $
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 _STGDIR_HXX
32 #define _STGDIR_HXX
34 #include "stgavl.hxx"
35 #include "stgelem.hxx"
36 #include "stgstrms.hxx"
38 class StgIo;
39 class StgEntry;
40 class StgDirEntry;
41 class StgDirStrm;
43 class BaseStorageStream;
44 class StgDirEntry : public StgAvlNode
46 friend class StgIterator;
47 friend class StgDirStrm;
48 StgEntry aSave; // original dir entry
49 StgDirEntry* pUp; // parent directory
50 StgDirEntry* pDown; // child directory for storages
51 StgDirEntry** ppRoot; // root of TOC tree
52 StgStrm* pStgStrm; // storage stream
53 StgTmpStrm* pTmpStrm; // temporary stream
54 StgTmpStrm* pCurStrm; // temp stream after commit
55 INT32 nEntry; // entry # in TOC stream (temp)
56 INT32 nPos; // current position
57 BOOL bDirty; // dirty directory entry
58 BOOL bCreated; // newly created entry
59 BOOL bRemoved; // removed per Invalidate()
60 BOOL bRenamed; // renamed
61 void InitMembers(); // ctor helper
62 virtual short Compare( const StgAvlNode* ) const;
63 BOOL StoreStream( StgIo& ); // store the stream
64 BOOL StoreStreams( StgIo& ); // store all streams
65 void RevertAll(); // revert the whole tree
66 BOOL Strm2Tmp(); // copy stgstream to temp file
67 BOOL Tmp2Strm(); // copy temp file to stgstream
68 public:
69 StgEntry aEntry; // entry data
70 INT32 nRefCnt; // reference count
71 StreamMode nMode; // open mode
72 BOOL bTemp; // TRUE: delete on dir flush
73 BOOL bDirect; // TRUE: direct mode
74 BOOL bZombie; // TRUE: Removed From StgIo
75 BOOL bInvalid; // TRUE: invalid entry
76 StgDirEntry( const void*, BOOL * pbOk );
77 StgDirEntry( const StgEntry& );
78 ~StgDirEntry();
80 void Invalidate( BOOL=FALSE ); // invalidate all open entries
81 void Enum( INT32& ); // enumerate entries for iteration
82 void DelTemp( BOOL ); // delete temporary entries
83 BOOL Store( StgDirStrm& ); // save entry into dir strm
84 BOOL IsContained( StgDirEntry* ); // check if subentry
86 void SetDirty() { bDirty = TRUE; }
87 BOOL IsDirty();
88 void ClearDirty();
90 BOOL Commit();
91 BOOL Revert();
93 void OpenStream( StgIo&, BOOL=FALSE ); // set up an approbiate stream
94 void Close();
95 INT32 GetSize();
96 BOOL SetSize( INT32 );
97 INT32 Seek( INT32 );
98 INT32 Tell() { return nPos; }
99 INT32 Read( void*, INT32 );
100 INT32 Write( const void*, INT32 );
101 void Copy( StgDirEntry& );
102 void Copy( BaseStorageStream& );
105 class StgDirStrm : public StgDataStrm
107 friend class StgIterator;
108 StgDirEntry* pRoot; // root of dir tree
109 short nEntries; // entries per page
110 void SetupEntry( INT32, StgDirEntry* );
111 public:
112 StgDirStrm( StgIo& );
113 ~StgDirStrm();
114 virtual BOOL SetSize( INT32 ); // change the size
115 BOOL Store();
116 void* GetEntry( INT32 n, BOOL=FALSE );// get an entry
117 StgDirEntry* GetRoot() { return pRoot; }
118 StgDirEntry* Find( StgDirEntry&, const String& );
119 StgDirEntry* Create( StgDirEntry&, const String&, StgEntryType );
120 BOOL Remove( StgDirEntry&, const String& );
121 BOOL Rename( StgDirEntry&, const String&, const String& );
122 BOOL Move( StgDirEntry&, StgDirEntry&, const String& );
125 class StgIterator : public StgAvlIterator
127 public:
128 StgIterator( StgDirEntry& rStg ) : StgAvlIterator( rStg.pDown ) {}
129 StgDirEntry* First() { return (StgDirEntry*) StgAvlIterator::First(); }
130 StgDirEntry* Next() { return (StgDirEntry*) StgAvlIterator::Next(); }
131 StgDirEntry* Last() { return (StgDirEntry*) StgAvlIterator::Last(); }
132 StgDirEntry* Prev() { return (StgDirEntry*) StgAvlIterator::Prev(); }
135 #endif