LibreOffice Module sw (master)  1
laycache.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_LAYCACHE_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_LAYCACHE_HXX
22 
23 #include <sal/types.h>
24 #include <memory>
25 
26 class SwDoc;
27 class SwLayCacheImpl;
28 class SvStream;
29 
30 /*
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.
40  */
42 {
43  std::unique_ptr<SwLayCacheImpl> pImpl;
44  sal_uInt16 nLockCount;
45 
46 public:
47  SwLayoutCache();
49 
50  void Read( SvStream &rStream );
51  static void Write( SvStream &rStream, const SwDoc& rDoc );
52 
53  void ClearImpl();
54  bool IsLocked() const { return nLockCount > 0; }
55  sal_uInt16& GetLockCount() { return nLockCount; }
57  { if( nLockCount & 0x8000 ) return nullptr;
58  if ( pImpl )
59  ++nLockCount;
60  return pImpl.get(); }
61  void UnlockImpl() { --nLockCount; }
62 
63 #ifdef DBG_UTIL
64  bool CompareLayout( const SwDoc& rDoc ) const;
65 #endif
66 };
67 #endif
68 
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ClearImpl()
Definition: laycache.cxx:440
static void Write(SvStream &rStream, const SwDoc &rDoc)
writes the index (more precise: the difference between the index and the first index of the document ...
Definition: laycache.cxx:163
std::unique_ptr< SwLayCacheImpl > pImpl
Definition: laycache.hxx:43
Definition: doc.hxx:185
void Read(SvStream &rStream)
Definition: laycache.cxx:68
sal_uInt16 nLockCount
Definition: laycache.hxx:44
SwLayCacheImpl * LockImpl()
Definition: laycache.hxx:56
sal_uInt16 & GetLockCount()
Definition: laycache.hxx:55
void UnlockImpl()
Definition: laycache.hxx:61
bool IsLocked() const
Definition: laycache.hxx:54
bool CompareLayout(const SwDoc &rDoc) const
Definition: laycache.cxx:325