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