xref: /AOO41X/main/sw/inc/unobaseclass.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 #ifndef SW_UNOBASECLASS_HXX
28 #define SW_UNOBASECLASS_HXX
29 
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/container/XEnumeration.hpp>
33 
34 #include <cppuhelper/implbase2.hxx>
35 
36 
37 class SfxPoolItem;
38 class SwClient;
39 class SwDoc;
40 
41 
42 typedef ::cppu::WeakImplHelper2
43 <   ::com::sun::star::lang::XServiceInfo
44 ,   ::com::sun::star::container::XEnumeration
45 >
46 SwSimpleEnumeration_Base;
47 
48 
49 /* -----------------29.04.98 07:35-------------------
50  *
51  * --------------------------------------------------*/
52 enum CursorType
53 {
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
67 };
68 
69 /*-----------------04.03.98 11:54-------------------
70     Start/EndAction or Start/EndAllAction
71   -------------------------------------------------- */
72 class UnoActionContext
73 {
74     private:
75         SwDoc * m_pDoc;
76 
77     public:
78         UnoActionContext(SwDoc *const pDoc);
79         ~UnoActionContext();
80 
81         void InvalidateDocument() { m_pDoc = 0; }
82 };
83 
84 /* -----------------07.07.98 12:03-------------------
85     interrupt Actions for a little while
86    -------------------------------------------------- */
87 class UnoActionRemoveContext
88 {
89     private:
90         SwDoc *const m_pDoc;
91 
92     public:
93         UnoActionRemoveContext(SwDoc *const pDoc);
94         ~UnoActionRemoveContext();
95 };
96 
97 
98 ::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId();
99 
100 /// helper function for implementing SwClient::Modify
101 void ClientModify(SwClient* pClient, const SfxPoolItem *pOld, const SfxPoolItem *pNew);
102 
103 
104 #include <boost/utility.hpp>
105 #include <osl/diagnose.h>
106 #include <vos/mutex.hxx>
107 #include <vcl/svapp.hxx>
108 
109 namespace sw {
110 
111     template<typename T> class UnoImplPtr
112         : private ::boost::noncopyable
113     {
114         private:
115             T * m_p;
116 
117         public:
118             UnoImplPtr(T *const i_p)
119                 : m_p(i_p)
120             {
121                 OSL_ENSURE(i_p, "UnoImplPtr: null");
122             }
123 
124             ~UnoImplPtr()
125             {
126                 ::vos::OGuard g(Application::GetSolarMutex());
127                 delete m_p; // #i105557#: call dtor with locked solar mutex
128                 m_p = 0;
129             }
130 
131             T & operator * () const { return *m_p; }
132 
133             T * operator ->() const { return  m_p; }
134 
135             T * get        () const { return  m_p; }
136     };
137 
138     template< class C > C *
139     UnoTunnelGetImplementation(
140             ::com::sun::star::uno::Reference<
141                 ::com::sun::star::lang::XUnoTunnel > const & xUnoTunnel)
142     {
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;
148     }
149 
150     template< class C > sal_Int64
151     UnoTunnelImpl(const ::com::sun::star::uno::Sequence< sal_Int8 > & rId,
152                   C *const pThis)
153     {
154         if ((rId.getLength() == 16) &&
155             (0 == rtl_compareMemory(C::getUnoTunnelId().getConstArray(),
156                                     rId.getConstArray(), 16)))
157         {
158             return ::sal::static_int_cast< sal_Int64 >(
159                     reinterpret_cast< sal_IntPtr >(pThis) );
160         }
161         return 0;
162     }
163 
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);
170 
171 } // namespace sw
172 
173 #endif // SW_UNOBASECLASS_HXX
174 
175