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 #ifndef _VCL_UNOHELP2_HXX 25 #define _VCL_UNOHELP2_HXX 26 27 #include <com/sun/star/datatransfer/XTransferable.hpp> 28 #include <cppuhelper/weak.hxx> 29 #include <tools/string.hxx> 30 #include <osl/mutex.hxx> 31 32 namespace com { namespace sun { namespace star { namespace datatransfer { namespace clipboard { 33 class XClipboard; 34 } } } } } 35 #include <vcl/dllapi.h> 36 37 namespace vcl { namespace unohelper { 38 39 class VCL_DLLPUBLIC TextDataObject : 40 public ::com::sun::star::datatransfer::XTransferable, 41 public ::cppu::OWeakObject 42 { 43 private: 44 String maText; 45 46 public: 47 TextDataObject( const String& rText ); 48 ~TextDataObject(); 49 GetString()50 String& GetString() { return maText; } 51 52 // ::com::sun::star::uno::XInterface 53 ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); acquire()54 void SAL_CALL acquire() throw() { OWeakObject::acquire(); } release()55 void SAL_CALL release() throw() { OWeakObject::release(); } 56 57 // ::com::sun::star::datatransfer::XTransferable 58 ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) throw(::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 59 ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) throw(::com::sun::star::uno::RuntimeException); 60 sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) throw(::com::sun::star::uno::RuntimeException); 61 62 /// copies a given string to a given clipboard 63 static void CopyStringTo( 64 const String& rContent, 65 const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard 66 ); 67 }; 68 69 struct MutexHelper 70 { 71 private: 72 ::osl::Mutex maMutex; 73 public: GetMutexvcl::unohelper::MutexHelper74 ::osl::Mutex& GetMutex() { return maMutex; } 75 }; 76 77 }} // namespace vcl::unohelper 78 79 #endif // _VCL_UNOHELP2_HXX 80 81