1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _LAYCACHE_HXX 28 #define _LAYCACHE_HXX 29 30 #include <tools/solar.h> 31 32 class SwDoc; 33 class SwLayCacheImpl; 34 class SvStream; 35 36 /************************************************************************* 37 * class SwLayoutCache 38 * 39 * This class allows to save layout information in the file and it contains 40 * this information after loading of a file. 41 * Call Write(..) with a stream and the document to save and the page break 42 * information of the document will be written. 43 * Call Read(..) with a stream and the member pLayCacheImpl will 44 * read the information from the stream and store it in an internal structur. 45 * There's a simple locking mechanism at these classes, 46 * if somebody reads the information, he increments the lock count by 1, 47 * during the Read(..) function the lock count will set to $8000. 48 * 49 **************************************************************************/ 50 51 class SwLayoutCache 52 { 53 SwLayCacheImpl *pImpl; 54 sal_uInt16 nLockCount; 55 public: 56 SwLayoutCache() : pImpl( NULL ), nLockCount( 0 ) {} 57 ~SwLayoutCache(); 58 59 void Read( SvStream &rStream ); 60 void Write( SvStream &rStream, const SwDoc& rDoc ); 61 62 void ClearImpl(); 63 sal_Bool IsLocked() const { return nLockCount > 0; } 64 sal_uInt16& GetLockCount() { return nLockCount; } 65 SwLayCacheImpl *LockImpl() 66 { if( nLockCount & 0x8000 ) return NULL; 67 if ( pImpl ) 68 ++nLockCount; 69 return pImpl; } 70 void UnlockImpl() { --nLockCount; } 71 72 #ifdef DBG_UTIL 73 sal_Bool CompareLayout( const SwDoc& rDoc ) const; 74 #endif 75 }; 76 77 #endif 78