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
26class SwDoc;
27class SwLayCacheImpl;
28class 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> m_pImpl;
44 sal_uInt16 m_nLockCount;
45
46public:
49
50 void Read( SvStream &rStream );
51 static void Write( SvStream &rStream, const SwDoc& rDoc );
52
53 void ClearImpl();
54 bool IsLocked() const { return m_nLockCount > 0; }
55 sal_uInt16& GetLockCount() { return m_nLockCount; }
57 { if( m_nLockCount & 0x8000 ) return nullptr;
58 if ( m_pImpl )
60 return m_pImpl.get(); }
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: */
Definition: doc.hxx:197
void ClearImpl()
Definition: laycache.cxx:440
std::unique_ptr< SwLayCacheImpl > m_pImpl
Definition: laycache.hxx:43
void UnlockImpl()
Definition: laycache.hxx:61
sal_uInt16 & GetLockCount()
Definition: laycache.hxx:55
sal_uInt16 m_nLockCount
Definition: laycache.hxx:44
SwLayCacheImpl * LockImpl()
Definition: laycache.hxx:56
void Read(SvStream &rStream)
Definition: laycache.cxx:68
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
bool IsLocked() const
Definition: laycache.hxx:54
bool CompareLayout(const SwDoc &rDoc) const
Definition: laycache.cxx:325