Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / sw / inc / unobaseclass.hxx
blobf72f07d5c83ae0f23f3d34e2f820f657f86e23e6
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 .
19 #ifndef INCLUDED_SW_INC_UNOBASECLASS_HXX
20 #define INCLUDED_SW_INC_UNOBASECLASS_HXX
22 #include <memory>
23 #include <com/sun/star/lang/XUnoTunnel.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/container/XEnumeration.hpp>
27 #include <cppuhelper/implbase.hxx>
28 #include <sal/log.hxx>
29 #include <osl/mutex.hxx>
30 #include <vcl/svapp.hxx>
32 class SfxPoolItem;
33 class SwClient;
34 class SwDoc;
35 class SwUnoTableCursor;
37 typedef ::cppu::WeakImplHelper
38 < css::lang::XServiceInfo
39 , css::container::XEnumeration
41 SwSimpleEnumeration_Base;
43 enum class CursorType
45 Body,
46 Frame,
47 TableText,
48 Footnote,
49 Header,
50 Footer,
51 Redline,
52 All, // for Search&Replace
53 Selection, // create a paragraph enumeration from
54 // a text range or cursor
55 SelectionInTable,
56 Meta, // meta/meta-field
60 Start/EndAction or Start/EndAllAction
62 class UnoActionContext
64 private:
65 SwDoc * m_pDoc;
67 public:
68 UnoActionContext(SwDoc *const pDoc);
69 ~UnoActionContext();
73 interrupt Actions for a little while
74 FIXME: this is a vile abomination that may cause recursive layout actions!
75 C'thulhu fhtagn.
77 class UnoActionRemoveContext
79 private:
80 SwDoc *const m_pDoc;
82 public:
83 UnoActionRemoveContext(SwDoc *const pDoc);
84 UnoActionRemoveContext(SwUnoTableCursor const& rCursor);
85 ~UnoActionRemoveContext();
88 /// helper function for implementing SwClient::Modify
89 void ClientModify(SwClient* pClient, const SfxPoolItem *pOld, const SfxPoolItem *pNew);
91 namespace sw {
92 template<typename T>
93 struct UnoImplPtrDeleter
95 void operator()(T* pUnoImpl)
97 SolarMutexGuard g; // #i105557#: call dtor with locked solar mutex
98 delete pUnoImpl;
101 /// Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex.
102 template<typename T>
103 using UnoImplPtr = std::unique_ptr<T, UnoImplPtrDeleter<T> >;
105 template< class C > C *
106 UnoTunnelGetImplementation( css::uno::Reference< css::lang::XUnoTunnel > const & xUnoTunnel)
108 if (!xUnoTunnel.is()) { return 0; }
109 C *const pC( reinterpret_cast< C* >(
110 ::sal::static_int_cast< sal_IntPtr >(
111 xUnoTunnel->getSomething(C::getUnoTunnelId()))));
112 return pC;
115 template< class C > sal_Int64
116 UnoTunnelImpl(const css::uno::Sequence< sal_Int8 > & rId,
117 C *const pThis)
119 if ((rId.getLength() == 16) &&
120 (0 == memcmp(C::getUnoTunnelId().getConstArray(),
121 rId.getConstArray(), 16)))
123 return ::sal::static_int_cast< sal_Int64 >(
124 reinterpret_cast< sal_IntPtr >(pThis) );
126 return 0;
129 css::uno::Sequence< OUString >
130 GetSupportedServiceNamesImpl(
131 size_t const nServices, char const*const pServices[]);
133 } // namespace sw
135 #endif // INCLUDED_SW_INC_UNOBASECLASS_HXX
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */