10d63794cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 30d63794cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 40d63794cSAndrew Rist * or more contributor license agreements. See the NOTICE file 50d63794cSAndrew Rist * distributed with this work for additional information 60d63794cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 70d63794cSAndrew Rist * to you under the Apache License, Version 2.0 (the 80d63794cSAndrew Rist * "License"); you may not use this file except in compliance 90d63794cSAndrew Rist * with the License. You may obtain a copy of the License at 100d63794cSAndrew Rist * 110d63794cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 120d63794cSAndrew Rist * 130d63794cSAndrew Rist * Unless required by applicable law or agreed to in writing, 140d63794cSAndrew Rist * software distributed under the License is distributed on an 150d63794cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 160d63794cSAndrew Rist * KIND, either express or implied. See the License for the 170d63794cSAndrew Rist * specific language governing permissions and limitations 180d63794cSAndrew Rist * under the License. 190d63794cSAndrew Rist * 200d63794cSAndrew Rist *************************************************************/ 210d63794cSAndrew Rist 220d63794cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _AQUA_CLIPBOARD_HXX_ 25cdf0e10cSrcweir #define _AQUA_CLIPBOARD_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "DataFlavorMapping.hxx" 28cdf0e10cSrcweir #include <rtl/ustring.hxx> 29cdf0e10cSrcweir #include <sal/types.h> 30cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx> 31cdf0e10cSrcweir #include <com/sun/star/datatransfer/XTransferable.hpp> 32cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp> 33cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp> 34cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp> 35cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp> 36cdf0e10cSrcweir #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp> 37cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp> 38cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 39cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx> 40cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <boost/utility.hpp> 43cdf0e10cSrcweir #include <list> 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include <premac.h> 46cdf0e10cSrcweir #import <Cocoa/Cocoa.h> 47cdf0e10cSrcweir #include <postmac.h> 48cdf0e10cSrcweir 49cdf0e10cSrcweir class AquaClipboard; 50cdf0e10cSrcweir 51cdf0e10cSrcweir @interface EventListener : NSObject 52cdf0e10cSrcweir { 53cdf0e10cSrcweir AquaClipboard* pAquaClipboard; 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir // Init the pasteboard change listener with a reference to the OfficeClipboard 57cdf0e10cSrcweir // instance 58cdf0e10cSrcweir - (EventListener*)initWithAquaClipboard: (AquaClipboard*) pcb; 59cdf0e10cSrcweir 60cdf0e10cSrcweir // Promiss resolver function 61*1cc6f0e2SHerbert Dürr - (void)pasteboard:(NSPasteboard*)sender provideDataForType:(const NSString *)type; 62cdf0e10cSrcweir 63cdf0e10cSrcweir -(void)applicationDidBecomeActive:(NSNotification*)aNotification; 64cdf0e10cSrcweir 65cdf0e10cSrcweir -(void)disposing; 66cdf0e10cSrcweir @end 67cdf0e10cSrcweir 68cdf0e10cSrcweir 69cdf0e10cSrcweir class AquaClipboard : public ::cppu::BaseMutex, 70cdf0e10cSrcweir public ::cppu::WeakComponentImplHelper4< com::sun::star::datatransfer::clipboard::XClipboardEx, 71cdf0e10cSrcweir com::sun::star::datatransfer::clipboard::XClipboardNotifier, 72cdf0e10cSrcweir com::sun::star::datatransfer::clipboard::XFlushableClipboard, 73cdf0e10cSrcweir com::sun::star::lang::XServiceInfo >, 74cdf0e10cSrcweir private ::boost::noncopyable 75cdf0e10cSrcweir { 76cdf0e10cSrcweir public: 77cdf0e10cSrcweir /* Create a clipboard instance. 78cdf0e10cSrcweir 79cdf0e10cSrcweir @param pasteboard 80cdf0e10cSrcweir If not equal NULL the instance will be instantiated with the provided 81cdf0e10cSrcweir pasteboard reference and 'bUseSystemClipboard' will be ignored 82cdf0e10cSrcweir 83cdf0e10cSrcweir @param bUseSystemClipboard 84cdf0e10cSrcweir If 'pasteboard' is NULL 'bUseSystemClipboard' determines whether the 85cdf0e10cSrcweir system clipboard will be created (bUseSystemClipboard == true) or if 86cdf0e10cSrcweir the DragPasteboard if bUseSystemClipboard == false 87cdf0e10cSrcweir */ 88cdf0e10cSrcweir AquaClipboard(NSPasteboard* pasteboard = NULL, 89cdf0e10cSrcweir bool bUseSystemClipboard = true); 90cdf0e10cSrcweir 91cdf0e10cSrcweir ~AquaClipboard(); 92cdf0e10cSrcweir 93cdf0e10cSrcweir //------------------------------------------------ 94cdf0e10cSrcweir // XClipboard 95cdf0e10cSrcweir //------------------------------------------------ 96cdf0e10cSrcweir 97cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents() 98cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir virtual void SAL_CALL setContents( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable, 101cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner ) 102cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 103cdf0e10cSrcweir 104cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getName() 105cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir //------------------------------------------------ 108cdf0e10cSrcweir // XClipboardEx 109cdf0e10cSrcweir //------------------------------------------------ 110cdf0e10cSrcweir 111cdf0e10cSrcweir virtual sal_Int8 SAL_CALL getRenderingCapabilities() 112cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir //------------------------------------------------ 115cdf0e10cSrcweir // XClipboardNotifier 116cdf0e10cSrcweir //------------------------------------------------ 117cdf0e10cSrcweir 118cdf0e10cSrcweir virtual void SAL_CALL addClipboardListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener ) 119cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 120cdf0e10cSrcweir 121cdf0e10cSrcweir virtual void SAL_CALL removeClipboardListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener ) 122cdf0e10cSrcweir throw( ::com::sun::star::uno::RuntimeException ); 123cdf0e10cSrcweir 124cdf0e10cSrcweir //------------------------------------------------ 125cdf0e10cSrcweir // XFlushableClipboard 126cdf0e10cSrcweir //------------------------------------------------ 127cdf0e10cSrcweir 128cdf0e10cSrcweir virtual void SAL_CALL flushClipboard( ) throw( com::sun::star::uno::RuntimeException ); 129cdf0e10cSrcweir 130cdf0e10cSrcweir //------------------------------------------------ 131cdf0e10cSrcweir // XServiceInfo 132cdf0e10cSrcweir //------------------------------------------------ 133cdf0e10cSrcweir 134cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() 135cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 136cdf0e10cSrcweir 137cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 138cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 139cdf0e10cSrcweir 140cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 141cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException); 142cdf0e10cSrcweir 143cdf0e10cSrcweir /* Get a reference to the used pastboard. 144cdf0e10cSrcweir */ 145cdf0e10cSrcweir NSPasteboard* getPasteboard() const; 146cdf0e10cSrcweir 147cdf0e10cSrcweir /* Notify the current clipboard owner that he is no longer the clipboard owner. 148cdf0e10cSrcweir */ 149cdf0e10cSrcweir void fireLostClipboardOwnershipEvent(::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner> oldOwner, 150cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > oldContent); 151cdf0e10cSrcweir 152cdf0e10cSrcweir void pasteboardChangedOwner(); 153cdf0e10cSrcweir 154*1cc6f0e2SHerbert Dürr void provideDataForType(NSPasteboard* sender, const NSString* type); 155cdf0e10cSrcweir 156cdf0e10cSrcweir void applicationDidBecomeActive(NSNotification* aNotification); 157cdf0e10cSrcweir 158cdf0e10cSrcweir private: 159cdf0e10cSrcweir 160cdf0e10cSrcweir /* Notify all registered XClipboardListener that the clipboard content 161cdf0e10cSrcweir has changed. 162cdf0e10cSrcweir */ 163cdf0e10cSrcweir void fireClipboardChangedEvent(); 164cdf0e10cSrcweir 165cdf0e10cSrcweir private: 166cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentTypeFactory > mrXMimeCntFactory; 167cdf0e10cSrcweir ::std::list< ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener > > mClipboardListeners; 168cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > mXClipboardContent; 169cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::datatransfer::clipboard::XClipboardOwner > mXClipboardOwner; 170cdf0e10cSrcweir DataFlavorMapperPtr_t mpDataFlavorMapper; 171cdf0e10cSrcweir bool mIsSystemPasteboard; 172cdf0e10cSrcweir NSPasteboard* mPasteboard; 173cdf0e10cSrcweir int mPasteboardChangeCount; 174cdf0e10cSrcweir EventListener* mEventListener; 175cdf0e10cSrcweir }; 176cdf0e10cSrcweir 177cdf0e10cSrcweir #endif 178