Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef SW_UNOBASECLASS_HXX
29 : : #define SW_UNOBASECLASS_HXX
30 : :
31 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
32 : : #include <com/sun/star/lang/XServiceInfo.hpp>
33 : : #include <com/sun/star/container/XEnumeration.hpp>
34 : :
35 : : #include <cppuhelper/implbase2.hxx>
36 : :
37 : :
38 : : class SfxPoolItem;
39 : : class SwClient;
40 : : class SwDoc;
41 : :
42 : :
43 : : typedef ::cppu::WeakImplHelper2
44 : : < ::com::sun::star::lang::XServiceInfo
45 : : , ::com::sun::star::container::XEnumeration
46 : : >
47 : : SwSimpleEnumeration_Base;
48 : :
49 : : enum CursorType
50 : : {
51 : : CURSOR_INVALID,
52 : : CURSOR_BODY,
53 : : CURSOR_FRAME,
54 : : CURSOR_TBLTEXT,
55 : : CURSOR_FOOTNOTE,
56 : : CURSOR_HEADER,
57 : : CURSOR_FOOTER,
58 : : CURSOR_REDLINE,
59 : : CURSOR_ALL, // for Search&Replace
60 : : CURSOR_SELECTION, // create a paragraph enumeration from
61 : : // a text range or cursor
62 : : CURSOR_SELECTION_IN_TABLE,
63 : : CURSOR_META, // meta/meta-field
64 : : };
65 : :
66 : : /*
67 : : Start/EndAction or Start/EndAllAction
68 : : */
69 : : class UnoActionContext
70 : : {
71 : : private:
72 : : SwDoc * m_pDoc;
73 : :
74 : : public:
75 : : UnoActionContext(SwDoc *const pDoc);
76 : : ~UnoActionContext();
77 : :
78 : : void InvalidateDocument() { m_pDoc = 0; }
79 : : };
80 : :
81 : : /*
82 : : interrupt Actions for a little while
83 : : */
84 : : class UnoActionRemoveContext
85 : : {
86 : : private:
87 : : SwDoc *const m_pDoc;
88 : :
89 : : public:
90 : : UnoActionRemoveContext(SwDoc *const pDoc);
91 : : ~UnoActionRemoveContext();
92 : : };
93 : :
94 : : /// helper function for implementing SwClient::Modify
95 : : void ClientModify(SwClient* pClient, const SfxPoolItem *pOld, const SfxPoolItem *pNew);
96 : :
97 : :
98 : : #include <boost/utility.hpp>
99 : : #include <osl/diagnose.h>
100 : : #include <osl/mutex.hxx>
101 : : #include <vcl/svapp.hxx>
102 : :
103 : : namespace sw {
104 : :
105 : : template<typename T> class UnoImplPtr
106 : : : private ::boost::noncopyable
107 : : {
108 : : private:
109 : : T * m_p;
110 : :
111 : : public:
112 : 58623 : UnoImplPtr(T *const i_p)
113 : 58623 : : m_p(i_p)
114 : : {
115 : : OSL_ENSURE(i_p, "UnoImplPtr: null");
116 : 58623 : }
117 : :
118 : 58539 : ~UnoImplPtr()
119 : : {
120 [ + - ][ + - ]: 58539 : SolarMutexGuard g;
[ + - ][ + - ]
121 [ + - ][ + - ]: 58539 : delete m_p; // #i105557#: call dtor with locked solar mutex
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
122 [ + - + - ]: 58539 : m_p = 0;
[ + - ][ + - ]
[ + - ]
123 : 58539 : }
124 : :
125 : : T & operator * () const { return *m_p; }
126 : :
127 : 614803 : T * operator ->() const { return m_p; }
128 : :
129 : 21156 : T * get () const { return m_p; }
130 : : };
131 : :
132 : : template< class C > C *
133 : 144159 : UnoTunnelGetImplementation(
134 : : ::com::sun::star::uno::Reference<
135 : : ::com::sun::star::lang::XUnoTunnel > const & xUnoTunnel)
136 : : {
137 [ - + ][ - + ]: 144159 : if (!xUnoTunnel.is()) { return 0; }
[ - + ][ - + ]
[ # # ][ - + ]
[ # # ][ - + ]
[ - + ][ # # ]
[ # # ]
138 : : C *const pC( reinterpret_cast< C* >(
139 : : ::sal::static_int_cast< sal_IntPtr >(
140 : 144159 : xUnoTunnel->getSomething(C::getUnoTunnelId()))));
141 : 144159 : return pC;
142 : : }
143 : :
144 : : template< class C > sal_Int64
145 : 142937 : UnoTunnelImpl(const ::com::sun::star::uno::Sequence< sal_Int8 > & rId,
146 : : C *const pThis)
147 : : {
148 [ + - ][ + + ]: 142937 : if ((rId.getLength() == 16) &&
[ + + ][ + - ]
[ + + ][ + + ]
149 : : (0 == memcmp(C::getUnoTunnelId().getConstArray(),
150 : : rId.getConstArray(), 16)))
151 : : {
152 : : return ::sal::static_int_cast< sal_Int64 >(
153 : 16610 : reinterpret_cast< sal_IntPtr >(pThis) );
154 : : }
155 : 142937 : return 0;
156 : : }
157 : :
158 : : ::com::sun::star::uno::Sequence< ::rtl::OUString >
159 : : GetSupportedServiceNamesImpl(
160 : : size_t const nServices, char const*const pServices[]);
161 : : sal_Bool SupportsServiceImpl(
162 : : size_t const nServices, char const*const pServices[],
163 : : ::rtl::OUString const & rServiceName);
164 : :
165 : : } // namespace sw
166 : :
167 : : #endif // SW_UNOBASECLASS_HXX
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|