calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / shell / inc / spsupp / COMRefCounted.hpp
blobf8027321a6c8fe7d721daa80eddb64220958086e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #ifndef INCLUDED_SHELL_INC_SPSUPP_COMREFCOUNTED_HPP
11 #define INCLUDED_SHELL_INC_SPSUPP_COMREFCOUNTED_HPP
13 #include <objbase.h>
14 #include <assert.h>
16 template <class... Interfaces>
17 class COMRefCounted : public Interfaces...
19 public:
20 virtual ~COMRefCounted() {}
22 // IUnknown methods
24 ULONG STDMETHODCALLTYPE AddRef() override
26 return static_cast<ULONG>(::InterlockedIncrement(&m_nRef));
29 ULONG STDMETHODCALLTYPE Release() override
31 assert(m_nRef > 0);
32 if (::InterlockedDecrement(&m_nRef) == 0)
34 delete this;
35 return 0;
37 return static_cast<ULONG>(m_nRef);
40 private:
41 LONG m_nRef = 1; // Created referenced
44 #endif
46 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */