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