summaryrefslogtreecommitdiff
path: root/sw/inc/BorderCacheOwner.hxx
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2021-01-23 01:09:49 +0100
committerBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2021-01-29 23:10:59 +0100
commitd77552970af7ffb9d06bcd57315979f317e94e2f (patch)
tree9ba78f893f57efc2ab0f8d542abb70032c240ee3 /sw/inc/BorderCacheOwner.hxx
parentc6ff20f1c101372be46a2583ec0c83ff021690a9 (diff)
remove SwCache bookkeeping from SwModify
- only very few classes (SwNode, SwFormat) are the "owners" of SwBorderAttrs in the SwCache - this bookkeeping should not be in such a fundamental class of writer - also: encapsulate most of the interaction with the cache in the new sw::BorderCacheOwner. This is mostly to protect the innocent user: * As interacting with the SwCache directly is very errorprone, because its glorious idea of using void* of the "owners" as keys to the entries. * In C++, reinterpret_cast<void*>(this) might be different along the class heirachy. This might easily slip under the radar of a casual user. Change-Id: I0da774b47885abf52f63aab8d93ebbf41dcf8040 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110112 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw/inc/BorderCacheOwner.hxx')
-rw-r--r--sw/inc/BorderCacheOwner.hxx49
1 files changed, 49 insertions, 0 deletions
diff --git a/sw/inc/BorderCacheOwner.hxx b/sw/inc/BorderCacheOwner.hxx
new file mode 100644
index 000000000000..6819aed3a8ca
--- /dev/null
+++ b/sw/inc/BorderCacheOwner.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_INC_CACHEOWNER_HXX
+#define INCLUDED_SW_INC_CACHEOWNER_HXX
+
+#include <sal/types.h>
+#include "swdllapi.h"
+
+class SwBorderAttrs;
+class SwBorderAttrAccess;
+
+namespace sw
+{
+/// Bookkeeping helper for SwCache caching writer borders.
+class SW_DLLPUBLIC BorderCacheOwner
+{
+private:
+ friend SwBorderAttrs;
+ friend SwBorderAttrAccess;
+ bool m_bInCache;
+
+public:
+ BorderCacheOwner()
+ : m_bInCache(false)
+ {
+ }
+ BorderCacheOwner(BorderCacheOwner&)
+ : m_bInCache(false)
+ {
+ }
+ BorderCacheOwner& operator=(const BorderCacheOwner&)
+ {
+ m_bInCache = false;
+ return *this;
+ }
+ ~BorderCacheOwner();
+ bool IsInCache() const { return m_bInCache; }
+ void InvalidateInSwCache(const sal_uInt16);
+};
+}
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */