Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef SW_UNOBASECLASS_HXX
20 : #define SW_UNOBASECLASS_HXX
21 :
22 : #include <com/sun/star/lang/XUnoTunnel.hpp>
23 : #include <com/sun/star/lang/XServiceInfo.hpp>
24 : #include <com/sun/star/container/XEnumeration.hpp>
25 :
26 : #include <cppuhelper/implbase2.hxx>
27 :
28 :
29 : class SfxPoolItem;
30 : class SwClient;
31 : class SwDoc;
32 :
33 :
34 : typedef ::cppu::WeakImplHelper2
35 : < ::com::sun::star::lang::XServiceInfo
36 : , ::com::sun::star::container::XEnumeration
37 : >
38 : SwSimpleEnumeration_Base;
39 :
40 : enum CursorType
41 : {
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
55 : };
56 :
57 : /*
58 : Start/EndAction or Start/EndAllAction
59 : */
60 : class UnoActionContext
61 : {
62 : private:
63 : SwDoc * m_pDoc;
64 :
65 : public:
66 : UnoActionContext(SwDoc *const pDoc);
67 : ~UnoActionContext();
68 :
69 : void InvalidateDocument() { m_pDoc = 0; }
70 : };
71 :
72 : /*
73 : interrupt Actions for a little while
74 : */
75 : class UnoActionRemoveContext
76 : {
77 : private:
78 : SwDoc *const m_pDoc;
79 :
80 : public:
81 : UnoActionRemoveContext(SwDoc *const pDoc);
82 : ~UnoActionRemoveContext();
83 : };
84 :
85 : /// helper function for implementing SwClient::Modify
86 : void ClientModify(SwClient* pClient, const SfxPoolItem *pOld, const SfxPoolItem *pNew);
87 :
88 :
89 : #include <boost/utility.hpp>
90 : #include <osl/diagnose.h>
91 : #include <osl/mutex.hxx>
92 : #include <vcl/svapp.hxx>
93 :
94 : namespace sw {
95 :
96 : template<typename T> class UnoImplPtr
97 : : private ::boost::noncopyable
98 : {
99 : private:
100 : T * m_p;
101 :
102 : public:
103 45822 : UnoImplPtr(T *const i_p)
104 45822 : : m_p(i_p)
105 : {
106 : OSL_ENSURE(i_p, "UnoImplPtr: null");
107 45822 : }
108 :
109 45573 : ~UnoImplPtr()
110 : {
111 45573 : SolarMutexGuard g;
112 45573 : delete m_p; // #i105557#: call dtor with locked solar mutex
113 45573 : m_p = 0;
114 45573 : }
115 :
116 : T & operator * () const { return *m_p; }
117 :
118 385549 : T * operator ->() const { return m_p; }
119 :
120 12305 : T * get () const { return m_p; }
121 : };
122 :
123 : template< class C > C *
124 84279 : UnoTunnelGetImplementation(
125 : ::com::sun::star::uno::Reference<
126 : ::com::sun::star::lang::XUnoTunnel > const & xUnoTunnel)
127 : {
128 84279 : if (!xUnoTunnel.is()) { return 0; }
129 : C *const pC( reinterpret_cast< C* >(
130 : ::sal::static_int_cast< sal_IntPtr >(
131 84279 : xUnoTunnel->getSomething(C::getUnoTunnelId()))));
132 84279 : return pC;
133 : }
134 :
135 : template< class C > sal_Int64
136 84361 : UnoTunnelImpl(const ::com::sun::star::uno::Sequence< sal_Int8 > & rId,
137 : C *const pThis)
138 : {
139 168722 : if ((rId.getLength() == 16) &&
140 84361 : (0 == memcmp(C::getUnoTunnelId().getConstArray(),
141 168722 : rId.getConstArray(), 16)))
142 : {
143 : return ::sal::static_int_cast< sal_Int64 >(
144 10046 : reinterpret_cast< sal_IntPtr >(pThis) );
145 : }
146 74315 : return 0;
147 : }
148 :
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);
155 :
156 : } // namespace sw
157 :
158 : #endif // SW_UNOBASECLASS_HXX
159 :
160 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|