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 24 25 #ifndef _WINCLIPBOARD_HXX_ 26 #define _WINCLIPBOARD_HXX_ 27 28 29 //------------------------------------------------------------------------ 30 // includes 31 //------------------------------------------------------------------------ 32 33 #include <rtl/ustring.hxx> 34 #include <sal/types.h> 35 #include <cppuhelper/compbase4.hxx> 36 #include <com/sun/star/datatransfer/XTransferable.hpp> 37 #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp> 38 #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp> 39 #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp> 40 #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp> 41 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp> 42 #include <com/sun/star/lang/XServiceInfo.hpp> 43 #include <osl/conditn.hxx> 44 45 #include <memory> 46 47 // forward 48 class CWinClipbImpl; 49 50 //------------------------------------------------------------------------ 51 // implements the XClipboard[Ex] ... interfaces 52 // for the clipboard viewer mechanism we need a static callback function 53 // and a static member to reasocciate from this static function to the 54 // class instance 55 // watch out: we are using only one static member variable and not a list 56 // because we assume to be instanciated only once 57 // this will be asured by an OneInstanceFactory of the service and not 58 // by this class! 59 //------------------------------------------------------------------------ 60 61 // helper class, so that the mutex is constructed 62 // before the constructor of WeakComponentImplHelper 63 // will be called and initialized with this mutex 64 class CWinClipboardDummy 65 { 66 protected: 67 osl::Mutex m_aMutex; 68 osl::Mutex m_aCbListenerMutex; 69 }; 70 71 class CWinClipboard : 72 public CWinClipboardDummy, 73 public cppu::WeakComponentImplHelper4< 74 ::com::sun::star::datatransfer::clipboard::XClipboardEx, \ 75 ::com::sun::star::datatransfer::clipboard::XFlushableClipboard, 76 ::com::sun::star::datatransfer::clipboard::XClipboardNotifier, 77 ::com::sun::star::lang::XServiceInfo > 78 { 79 public: 80 CWinClipboard( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager, 81 const ::rtl::OUString& aClipboardName ); 82 83 //------------------------------------------------ 84 // XClipboard 85 //------------------------------------------------ 86 87 virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents( ) 88 throw( ::com::sun::star::uno::RuntimeException ); 89 90 virtual void SAL_CALL setContents( 91 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable, 92 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner ) 93 throw( ::com::sun::star::uno::RuntimeException ); 94 95 virtual ::rtl::OUString SAL_CALL getName( ) 96 throw( ::com::sun::star::uno::RuntimeException ); 97 98 //------------------------------------------------ 99 // XFlushableClipboard 100 //------------------------------------------------ 101 102 virtual void SAL_CALL flushClipboard( ) throw( com::sun::star::uno::RuntimeException ); 103 104 //------------------------------------------------ 105 // XClipboardEx 106 //------------------------------------------------ 107 108 virtual sal_Int8 SAL_CALL getRenderingCapabilities( ) throw( ::com::sun::star::uno::RuntimeException ); 109 110 //------------------------------------------------ 111 // XClipboardNotifier 112 //------------------------------------------------ 113 114 virtual void SAL_CALL addClipboardListener( 115 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener ) 116 throw( ::com::sun::star::uno::RuntimeException ); 117 118 virtual void SAL_CALL removeClipboardListener( 119 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener ) 120 throw( ::com::sun::star::uno::RuntimeException ); 121 122 //------------------------------------------------ 123 // overwrite base class method, which is called 124 // by base class dispose function 125 //------------------------------------------------ 126 127 virtual void SAL_CALL disposing(); 128 129 //------------------------------------------------ 130 // XServiceInfo 131 //------------------------------------------------ 132 133 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 134 throw(::com::sun::star::uno::RuntimeException); 135 136 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 137 throw(::com::sun::star::uno::RuntimeException); 138 139 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 140 throw(::com::sun::star::uno::RuntimeException); 141 142 private: 143 void SAL_CALL notifyAllClipboardListener( ); 144 145 private: 146 ::std::auto_ptr< CWinClipbImpl > m_pImpl; 147 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_SrvMgr; 148 149 friend class CWinClipbImpl; 150 }; 151 152 153 #endif 154