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 instantiated only once 57 // this will be assured 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 89 virtual void SAL_CALL setContents( 90 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable, 91 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner ); 92 93 virtual ::rtl::OUString SAL_CALL getName( ); 94 95 //------------------------------------------------ 96 // XFlushableClipboard 97 //------------------------------------------------ 98 99 virtual void SAL_CALL flushClipboard( ); 100 101 //------------------------------------------------ 102 // XClipboardEx 103 //------------------------------------------------ 104 105 virtual sal_Int8 SAL_CALL getRenderingCapabilities( ); 106 107 //------------------------------------------------ 108 // XClipboardNotifier 109 //------------------------------------------------ 110 111 virtual void SAL_CALL addClipboardListener( 112 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener ); 113 114 virtual void SAL_CALL removeClipboardListener( 115 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener ); 116 117 //------------------------------------------------ 118 // overwrite base class method, which is called 119 // by base class dispose function 120 //------------------------------------------------ 121 122 virtual void SAL_CALL disposing(); 123 124 //------------------------------------------------ 125 // XServiceInfo 126 //------------------------------------------------ 127 128 virtual ::rtl::OUString SAL_CALL getImplementationName( ); 129 130 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ); 131 132 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ); 133 134 private: 135 void SAL_CALL notifyAllClipboardListener( ); 136 137 private: 138 ::std::auto_ptr< CWinClipbImpl > m_pImpl; 139 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_SrvMgr; 140 141 friend class CWinClipbImpl; 142 }; 143 144 145 #endif 146