bump product version to 4.1.6.2
[LibreOffice.git] / sw / inc / unobaseclass.hxx
blob3537cd2769ccd9c749bf66b4be6f0477b4903c2c
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 SW_UNOBASECLASS_HXX
20 #define SW_UNOBASECLASS_HXX
22 #include <com/sun/star/lang/XUnoTunnel.hpp>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/container/XEnumeration.hpp>
26 #include <cppuhelper/implbase2.hxx>
29 class SfxPoolItem;
30 class SwClient;
31 class SwDoc;
34 typedef ::cppu::WeakImplHelper2
35 < ::com::sun::star::lang::XServiceInfo
36 , ::com::sun::star::container::XEnumeration
38 SwSimpleEnumeration_Base;
40 enum CursorType
42 CURSOR_INVALID,
43 CURSOR_BODY,
44 CURSOR_FRAME,
45 CURSOR_TBLTEXT,
46 CURSOR_FOOTNOTE,
47 CURSOR_HEADER,
48 CURSOR_FOOTER,
49 CURSOR_REDLINE,
50 CURSOR_ALL, // for Search&Replace
51 CURSOR_SELECTION, // create a paragraph enumeration from
52 // a text range or cursor
53 CURSOR_SELECTION_IN_TABLE,
54 CURSOR_META, // meta/meta-field
58 Start/EndAction or Start/EndAllAction
60 class UnoActionContext
62 private:
63 SwDoc * m_pDoc;
65 public:
66 UnoActionContext(SwDoc *const pDoc);
67 ~UnoActionContext();
69 void InvalidateDocument() { m_pDoc = 0; }
73 interrupt Actions for a little while
75 class UnoActionRemoveContext
77 private:
78 SwDoc *const m_pDoc;
80 public:
81 UnoActionRemoveContext(SwDoc *const pDoc);
82 ~UnoActionRemoveContext();
85 /// helper function for implementing SwClient::Modify
86 void ClientModify(SwClient* pClient, const SfxPoolItem *pOld, const SfxPoolItem *pNew);
89 #include <boost/utility.hpp>
90 #include <osl/diagnose.h>
91 #include <osl/mutex.hxx>
92 #include <vcl/svapp.hxx>
94 namespace sw {
96 template<typename T> class UnoImplPtr
97 : private ::boost::noncopyable
99 private:
100 T * m_p;
102 public:
103 UnoImplPtr(T *const i_p)
104 : m_p(i_p)
106 OSL_ENSURE(i_p, "UnoImplPtr: null");
109 ~UnoImplPtr()
111 SolarMutexGuard g;
112 delete m_p; // #i105557#: call dtor with locked solar mutex
113 m_p = 0;
116 T & operator * () const { return *m_p; }
118 T * operator ->() const { return m_p; }
120 T * get () const { return m_p; }
123 template< class C > C *
124 UnoTunnelGetImplementation(
125 ::com::sun::star::uno::Reference<
126 ::com::sun::star::lang::XUnoTunnel > const & xUnoTunnel)
128 if (!xUnoTunnel.is()) { return 0; }
129 C *const pC( reinterpret_cast< C* >(
130 ::sal::static_int_cast< sal_IntPtr >(
131 xUnoTunnel->getSomething(C::getUnoTunnelId()))));
132 return pC;
135 template< class C > sal_Int64
136 UnoTunnelImpl(const ::com::sun::star::uno::Sequence< sal_Int8 > & rId,
137 C *const pThis)
139 if ((rId.getLength() == 16) &&
140 (0 == memcmp(C::getUnoTunnelId().getConstArray(),
141 rId.getConstArray(), 16)))
143 return ::sal::static_int_cast< sal_Int64 >(
144 reinterpret_cast< sal_IntPtr >(pThis) );
146 return 0;
149 ::com::sun::star::uno::Sequence< OUString >
150 GetSupportedServiceNamesImpl(
151 size_t const nServices, char const*const pServices[]);
152 sal_Bool SupportsServiceImpl(
153 size_t const nServices, char const*const pServices[],
154 OUString const & rServiceName);
156 } // namespace sw
158 #endif // SW_UNOBASECLASS_HXX
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */