merged tag ooo/OOO330_m14
[LibreOffice.git] / sw / inc / unobaseclass.hxx
blob6c12a01b0d479b8822cda7101fde2d93096f9a9a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef SW_UNOBASECLASS_HXX
28 #define SW_UNOBASECLASS_HXX
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/container/XEnumeration.hpp>
34 #include <cppuhelper/implbase2.hxx>
37 class SfxPoolItem;
38 class SwClient;
39 class SwDoc;
42 typedef ::cppu::WeakImplHelper2
43 < ::com::sun::star::lang::XServiceInfo
44 , ::com::sun::star::container::XEnumeration
46 SwSimpleEnumeration_Base;
49 /* -----------------29.04.98 07:35-------------------
51 * --------------------------------------------------*/
52 enum CursorType
54 CURSOR_INVALID,
55 CURSOR_BODY,
56 CURSOR_FRAME,
57 CURSOR_TBLTEXT,
58 CURSOR_FOOTNOTE,
59 CURSOR_HEADER,
60 CURSOR_FOOTER,
61 CURSOR_REDLINE,
62 CURSOR_ALL, // for Search&Replace
63 CURSOR_SELECTION, // create a paragraph enumeration from
64 // a text range or cursor
65 CURSOR_SELECTION_IN_TABLE,
66 CURSOR_META, // meta/meta-field
69 /*-----------------04.03.98 11:54-------------------
70 Start/EndAction or Start/EndAllAction
71 -------------------------------------------------- */
72 class UnoActionContext
74 private:
75 SwDoc * m_pDoc;
77 public:
78 UnoActionContext(SwDoc *const pDoc);
79 ~UnoActionContext();
81 void InvalidateDocument() { m_pDoc = 0; }
84 /* -----------------07.07.98 12:03-------------------
85 interrupt Actions for a little while
86 -------------------------------------------------- */
87 class UnoActionRemoveContext
89 private:
90 SwDoc *const m_pDoc;
92 public:
93 UnoActionRemoveContext(SwDoc *const pDoc);
94 ~UnoActionRemoveContext();
98 ::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId();
100 /// helper function for implementing SwClient::Modify
101 void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew);
104 #include <boost/utility.hpp>
105 #include <osl/diagnose.h>
106 #include <vos/mutex.hxx>
107 #include <vcl/svapp.hxx>
109 namespace sw {
111 template<typename T> class UnoImplPtr
112 : private ::boost::noncopyable
114 private:
115 T * m_p;
117 public:
118 UnoImplPtr(T *const i_p)
119 : m_p(i_p)
121 OSL_ENSURE(i_p, "UnoImplPtr: null");
124 ~UnoImplPtr()
126 ::vos::OGuard g(Application::GetSolarMutex());
127 delete m_p; // #i105557#: call dtor with locked solar mutex
128 m_p = 0;
131 T & operator * () const { return *m_p; }
133 T * operator ->() const { return m_p; }
135 T * get () const { return m_p; }
138 template< class C > C *
139 UnoTunnelGetImplementation(
140 ::com::sun::star::uno::Reference<
141 ::com::sun::star::lang::XUnoTunnel > const & xUnoTunnel)
143 if (!xUnoTunnel.is()) { return 0; }
144 C *const pC( reinterpret_cast< C* >(
145 ::sal::static_int_cast< sal_IntPtr >(
146 xUnoTunnel->getSomething(C::getUnoTunnelId()))));
147 return pC;
150 template< class C > sal_Int64
151 UnoTunnelImpl(const ::com::sun::star::uno::Sequence< sal_Int8 > & rId,
152 C *const pThis)
154 if ((rId.getLength() == 16) &&
155 (0 == rtl_compareMemory(C::getUnoTunnelId().getConstArray(),
156 rId.getConstArray(), 16)))
158 return ::sal::static_int_cast< sal_Int64 >(
159 reinterpret_cast< sal_IntPtr >(pThis) );
161 return 0;
164 ::com::sun::star::uno::Sequence< ::rtl::OUString >
165 GetSupportedServiceNamesImpl(
166 size_t const nServices, char const*const pServices[]);
167 sal_Bool SupportsServiceImpl(
168 size_t const nServices, char const*const pServices[],
169 ::rtl::OUString const & rServiceName);
171 } // namespace sw
173 #endif // SW_UNOBASECLASS_HXX