xref: /aoo4110/main/sw/source/core/inc/laycache.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _LAYCACHE_HXX
24 #define _LAYCACHE_HXX
25 
26 #include <tools/solar.h>
27 
28 class SwDoc;
29 class SwLayCacheImpl;
30 class SvStream;
31 
32 /*************************************************************************
33  *                      class SwLayoutCache
34  *
35  * This class allows to save layout information in the file and it contains
36  * this information after loading of a file.
37  * Call Write(..) with a stream and the document to save and the page break
38  * information of the document will be written.
39  * Call Read(..) with a stream and the member pLayCacheImpl will
40  * read the information from the stream and store it in an internal structur.
41  * There's a simple locking mechanism at these classes,
42  * if somebody reads the information, he increments the lock count by 1,
43  * during the Read(..) function the lock count will set to $8000.
44  *
45  **************************************************************************/
46 
47 class SwLayoutCache
48 {
49     SwLayCacheImpl *pImpl;
50     sal_uInt16 nLockCount;
51 public:
SwLayoutCache()52     SwLayoutCache() : pImpl( NULL ), nLockCount( 0 ) {}
53     ~SwLayoutCache();
54 
55     void Read( SvStream &rStream );
56     void Write( SvStream &rStream, const SwDoc& rDoc );
57 
58     void ClearImpl();
IsLocked() const59     sal_Bool IsLocked() const { return nLockCount > 0; }
GetLockCount()60     sal_uInt16& GetLockCount() { return nLockCount; }
LockImpl()61     SwLayCacheImpl *LockImpl()
62         { if( nLockCount & 0x8000 ) return NULL;
63           if ( pImpl )
64             ++nLockCount;
65           return pImpl; }
UnlockImpl()66     void UnlockImpl() { --nLockCount; }
67 
68 #ifdef DBG_UTIL
69     sal_Bool CompareLayout( const SwDoc& rDoc ) const;
70 #endif
71 };
72 
73 #endif
74