xref: /trunk/main/sw/inc/unobaseclass.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef SW_UNOBASECLASS_HXX
24cdf0e10cSrcweir #define SW_UNOBASECLASS_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
27cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
28cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
33cdf0e10cSrcweir class SfxPoolItem;
34cdf0e10cSrcweir class SwClient;
35cdf0e10cSrcweir class SwDoc;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir typedef ::cppu::WeakImplHelper2
39cdf0e10cSrcweir <   ::com::sun::star::lang::XServiceInfo
40cdf0e10cSrcweir ,   ::com::sun::star::container::XEnumeration
41cdf0e10cSrcweir >
42cdf0e10cSrcweir SwSimpleEnumeration_Base;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 
45cdf0e10cSrcweir /* -----------------29.04.98 07:35-------------------
46cdf0e10cSrcweir  *
47cdf0e10cSrcweir  * --------------------------------------------------*/
48cdf0e10cSrcweir enum CursorType
49cdf0e10cSrcweir {
50cdf0e10cSrcweir     CURSOR_INVALID,
51cdf0e10cSrcweir     CURSOR_BODY,
52cdf0e10cSrcweir     CURSOR_FRAME,
53cdf0e10cSrcweir     CURSOR_TBLTEXT,
54cdf0e10cSrcweir     CURSOR_FOOTNOTE,
55cdf0e10cSrcweir     CURSOR_HEADER,
56cdf0e10cSrcweir     CURSOR_FOOTER,
57cdf0e10cSrcweir     CURSOR_REDLINE,
58cdf0e10cSrcweir     CURSOR_ALL,         // for Search&Replace
59cdf0e10cSrcweir     CURSOR_SELECTION,   // create a paragraph enumeration from
60cdf0e10cSrcweir                         // a text range or cursor
61cdf0e10cSrcweir     CURSOR_SELECTION_IN_TABLE,
62cdf0e10cSrcweir     CURSOR_META,         // meta/meta-field
63cdf0e10cSrcweir };
64cdf0e10cSrcweir 
65cdf0e10cSrcweir /*-----------------04.03.98 11:54-------------------
66cdf0e10cSrcweir     Start/EndAction or Start/EndAllAction
67cdf0e10cSrcweir   -------------------------------------------------- */
68cdf0e10cSrcweir class UnoActionContext
69cdf0e10cSrcweir {
70cdf0e10cSrcweir     private:
71cdf0e10cSrcweir         SwDoc * m_pDoc;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     public:
74cdf0e10cSrcweir         UnoActionContext(SwDoc *const pDoc);
75cdf0e10cSrcweir         ~UnoActionContext();
76cdf0e10cSrcweir 
InvalidateDocument()77cdf0e10cSrcweir         void InvalidateDocument() { m_pDoc = 0; }
78cdf0e10cSrcweir };
79cdf0e10cSrcweir 
80cdf0e10cSrcweir /* -----------------07.07.98 12:03-------------------
81cdf0e10cSrcweir     interrupt Actions for a little while
82cdf0e10cSrcweir    -------------------------------------------------- */
83cdf0e10cSrcweir class UnoActionRemoveContext
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     private:
86cdf0e10cSrcweir         SwDoc *const m_pDoc;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     public:
89cdf0e10cSrcweir         UnoActionRemoveContext(SwDoc *const pDoc);
90cdf0e10cSrcweir         ~UnoActionRemoveContext();
91cdf0e10cSrcweir };
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
94cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId();
95cdf0e10cSrcweir 
96cdf0e10cSrcweir /// helper function for implementing SwClient::Modify
97cdf0e10cSrcweir void ClientModify(SwClient* pClient, const SfxPoolItem *pOld, const SfxPoolItem *pNew);
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir #include <boost/utility.hpp>
101cdf0e10cSrcweir #include <osl/diagnose.h>
102cdf0e10cSrcweir #include <vos/mutex.hxx>
103cdf0e10cSrcweir #include <vcl/svapp.hxx>
104cdf0e10cSrcweir 
105cdf0e10cSrcweir namespace sw {
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     template<typename T> class UnoImplPtr
108cdf0e10cSrcweir         : private ::boost::noncopyable
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir         private:
111cdf0e10cSrcweir             T * m_p;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir         public:
UnoImplPtr(T * const i_p)114cdf0e10cSrcweir             UnoImplPtr(T *const i_p)
115cdf0e10cSrcweir                 : m_p(i_p)
116cdf0e10cSrcweir             {
117cdf0e10cSrcweir                 OSL_ENSURE(i_p, "UnoImplPtr: null");
118cdf0e10cSrcweir             }
119cdf0e10cSrcweir 
~UnoImplPtr()120cdf0e10cSrcweir             ~UnoImplPtr()
121cdf0e10cSrcweir             {
122cdf0e10cSrcweir                 ::vos::OGuard g(Application::GetSolarMutex());
123cdf0e10cSrcweir                 delete m_p; // #i105557#: call dtor with locked solar mutex
124cdf0e10cSrcweir                 m_p = 0;
125cdf0e10cSrcweir             }
126cdf0e10cSrcweir 
operator *() const127cdf0e10cSrcweir             T & operator * () const { return *m_p; }
128cdf0e10cSrcweir 
operator ->() const129cdf0e10cSrcweir             T * operator ->() const { return  m_p; }
130cdf0e10cSrcweir 
get() const131cdf0e10cSrcweir             T * get        () const { return  m_p; }
132cdf0e10cSrcweir     };
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     template< class C > C *
UnoTunnelGetImplementation(::com::sun::star::uno::Reference<::com::sun::star::lang::XUnoTunnel> const & xUnoTunnel)135cdf0e10cSrcweir     UnoTunnelGetImplementation(
136cdf0e10cSrcweir             ::com::sun::star::uno::Reference<
137cdf0e10cSrcweir                 ::com::sun::star::lang::XUnoTunnel > const & xUnoTunnel)
138cdf0e10cSrcweir     {
139cdf0e10cSrcweir         if (!xUnoTunnel.is()) { return 0; }
140cdf0e10cSrcweir         C *const pC( reinterpret_cast< C* >(
141cdf0e10cSrcweir                         ::sal::static_int_cast< sal_IntPtr >(
142cdf0e10cSrcweir                             xUnoTunnel->getSomething(C::getUnoTunnelId()))));
143cdf0e10cSrcweir         return pC;
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     template< class C > sal_Int64
UnoTunnelImpl(const::com::sun::star::uno::Sequence<sal_Int8> & rId,C * const pThis)147cdf0e10cSrcweir     UnoTunnelImpl(const ::com::sun::star::uno::Sequence< sal_Int8 > & rId,
148cdf0e10cSrcweir                   C *const pThis)
149cdf0e10cSrcweir     {
150cdf0e10cSrcweir         if ((rId.getLength() == 16) &&
151cdf0e10cSrcweir             (0 == rtl_compareMemory(C::getUnoTunnelId().getConstArray(),
152cdf0e10cSrcweir                                     rId.getConstArray(), 16)))
153cdf0e10cSrcweir         {
154cdf0e10cSrcweir             return ::sal::static_int_cast< sal_Int64 >(
155cdf0e10cSrcweir                     reinterpret_cast< sal_IntPtr >(pThis) );
156cdf0e10cSrcweir         }
157cdf0e10cSrcweir         return 0;
158cdf0e10cSrcweir     }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString >
161cdf0e10cSrcweir     GetSupportedServiceNamesImpl(
162cdf0e10cSrcweir             size_t const nServices, char const*const pServices[]);
163cdf0e10cSrcweir     sal_Bool SupportsServiceImpl(
164cdf0e10cSrcweir             size_t const nServices, char const*const pServices[],
165cdf0e10cSrcweir             ::rtl::OUString const & rServiceName);
166cdf0e10cSrcweir 
167cdf0e10cSrcweir } // namespace sw
168cdf0e10cSrcweir 
169cdf0e10cSrcweir #endif // SW_UNOBASECLASS_HXX
170cdf0e10cSrcweir 
171