Update ooo320-m1
[ooovba.git] / sw / source / core / inc / laycache.hxx
blob60414797b541e0ddd483a839989b474c9cc8b032
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: laycache.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 ************************************************************************/
30 #ifndef _LAYCACHE_HXX
31 #define _LAYCACHE_HXX
33 #include <tools/solar.h>
35 class SwDoc;
36 class SwLayCacheImpl;
37 class SvStream;
39 /*************************************************************************
40 * class SwLayoutCache
42 * This class allows to save layout information in the file and it contains
43 * this information after loading of a file.
44 * Call Write(..) with a stream and the document to save and the page break
45 * information of the document will be written.
46 * Call Read(..) with a stream and the member pLayCacheImpl will
47 * read the information from the stream and store it in an internal structur.
48 * There's a simple locking mechanism at these classes,
49 * if somebody reads the information, he increments the lock count by 1,
50 * during the Read(..) function the lock count will set to $8000.
52 **************************************************************************/
54 class SwLayoutCache
56 SwLayCacheImpl *pImpl;
57 USHORT nLockCount;
58 public:
59 SwLayoutCache() : pImpl( NULL ), nLockCount( 0 ) {}
60 ~SwLayoutCache();
62 void Read( SvStream &rStream );
63 void Write( SvStream &rStream, const SwDoc& rDoc );
65 void ClearImpl();
66 sal_Bool IsLocked() const { return nLockCount > 0; }
67 USHORT& GetLockCount() { return nLockCount; }
68 SwLayCacheImpl *LockImpl()
69 { if( nLockCount & 0x8000 ) return NULL;
70 if ( pImpl )
71 ++nLockCount;
72 return pImpl; }
73 void UnlockImpl() { --nLockCount; }
75 #ifndef PRODUCT
76 sal_Bool CompareLayout( const SwDoc& rDoc ) const;
77 #endif
80 #endif