1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_LAYCACHE_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_LAYCACHE_HXX
23 #include <sal/types.h>
31 * This class allows to save layout information in the file and it contains
32 * this information after loading of a file.
33 * Call Write(..) with a stream and the document to save and the page break
34 * information of the document will be written.
35 * Call Read(..) with a stream and the member pLayCacheImpl will
36 * read the information from the stream and store it in an internal structure.
37 * There's a simple locking mechanism at these classes,
38 * if somebody reads the information, he increments the lock count by 1,
39 * during the Read(..) function the lock count will set to $8000.
43 std::unique_ptr
<SwLayCacheImpl
> m_pImpl
;
44 sal_uInt16 m_nLockCount
;
50 void Read( SvStream
&rStream
);
51 static void Write( SvStream
&rStream
, const SwDoc
& rDoc
);
54 bool IsLocked() const { return m_nLockCount
> 0; }
55 sal_uInt16
& GetLockCount() { return m_nLockCount
; }
56 SwLayCacheImpl
*LockImpl()
57 { if( m_nLockCount
& 0x8000 ) return nullptr;
60 return m_pImpl
.get(); }
61 void UnlockImpl() { --m_nLockCount
; }
64 bool CompareLayout( const SwDoc
& rDoc
) const;
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */