calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / dbaccess / source / core / misc / apitools.cxx
blobefec92cf5a63dfba61dc57cec8f158f98b4c9652
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/.
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 #include <apitools.hxx>
21 #include <cppuhelper/typeprovider.hxx>
22 #include <sal/log.hxx>
24 using namespace ::com::sun::star::uno;
25 using namespace ::com::sun::star::lang;
26 using namespace cppu;
27 using namespace osl;
29 // various helper functions
30 // OSubComponent
31 OSubComponent::OSubComponent(Mutex& _rMutex, const Reference< XInterface > & xParent)
32 :OComponentHelper(_rMutex)
33 ,m_xParent(xParent)
38 OSubComponent::~OSubComponent()
40 m_xParent = nullptr;
44 // css::lang::XTypeProvider
45 Sequence< Type > OSubComponent::getTypes()
47 OTypeCollection aTypes(cppu::UnoType<XComponent>::get(),
48 cppu::UnoType<XTypeProvider>::get(),
49 cppu::UnoType<XWeak>::get());
51 return aTypes.getTypes();
54 // XInterface
56 void OSubComponent::release() noexcept
58 Reference< XInterface > x( xDelegator );
59 if (! x.is())
61 if (osl_atomic_decrement( &m_refCount ) == 0 )
63 if (! rBHelper.bDisposed)
65 // *before* again incrementing our ref count, ensure that our weak connection point
66 // will not create references to us anymore (via XAdapter::queryAdapted)
67 disposeWeakConnectionPoint();
69 Reference< XInterface > xHoldAlive( *this );
70 // remember the parent
71 Reference< XInterface > xParent;
73 MutexGuard aGuard( rBHelper.rMutex );
74 xParent = m_xParent;
75 m_xParent = nullptr;
78 SAL_WARN_IF( m_refCount != 1, "dbaccess.core", "OSubComponent::release: invalid ref count (before dispose)!" );
80 // First dispose
81 dispose();
83 // only the alive ref holds the object
84 SAL_WARN_IF( m_refCount != 1, "dbaccess.core", "OSubComponent::release: invalid ref count (after dispose)!" );
86 // release the parent in the ~
87 if (xParent.is())
89 MutexGuard aGuard( rBHelper.rMutex );
90 m_xParent = xParent;
93 // destroy the object if xHoldAlive decrement the refcount to 0
94 return;
97 // restore the reference count
98 osl_atomic_increment( &m_refCount );
101 // as we cover the job of the componenthelper we use the ...
102 OWeakAggObject::release();
105 Any OSubComponent::queryInterface( const Type & rType )
107 Any aReturn;
108 if (!rType.equals(cppu::UnoType<XAggregation>::get()))
109 aReturn = OComponentHelper::queryInterface(rType);
111 return aReturn;
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */