Look for libboostrap.uno.so and not bootstrap.uno.so on Android
[LibreOffice.git] / basctl / source / dlged / dlgedclip.cxx
blob17392b2510ac474fcc84d91259b205a1cee446d7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_basctl.hxx"
31 #include "dlgedclip.hxx"
32 #include <osl/mutex.hxx>
33 #include <vcl/svapp.hxx>
34 #include <comphelper/processfactory.hxx>
35 #include <com/sun/star/datatransfer/XMimeContentType.hpp>
36 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
39 using namespace comphelper;
40 using namespace ::com::sun::star;
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::io;
43 using namespace ::com::sun::star::datatransfer;
44 using namespace ::com::sun::star::datatransfer::clipboard;
47 //----------------------------------------------------------------------------
49 DlgEdTransferableImpl::DlgEdTransferableImpl( const Sequence< DataFlavor >& aSeqFlavors, const Sequence< Any >& aSeqData )
51 m_SeqFlavors = aSeqFlavors;
52 m_SeqData = aSeqData;
55 //----------------------------------------------------------------------------
57 DlgEdTransferableImpl::~DlgEdTransferableImpl()
61 //----------------------------------------------------------------------------
63 sal_Bool DlgEdTransferableImpl::compareDataFlavors( const DataFlavor& lFlavor, const DataFlavor& rFlavor )
65 sal_Bool bRet = sal_False;
67 // compare mime content types
68 Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
69 Reference< datatransfer::XMimeContentTypeFactory >
70 xMCntTypeFactory( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.datatransfer.MimeContentTypeFactory" ) ) ), UNO_QUERY );
72 if ( xMCntTypeFactory.is( ) )
74 // compare full media types
75 Reference< datatransfer::XMimeContentType > xLType = xMCntTypeFactory->createMimeContentType( lFlavor.MimeType );
76 Reference< datatransfer::XMimeContentType > xRType = xMCntTypeFactory->createMimeContentType( rFlavor.MimeType );
78 ::rtl::OUString aLFullMediaType = xLType->getFullMediaType();
79 ::rtl::OUString aRFullMediaType = xRType->getFullMediaType();
81 bRet = aLFullMediaType.equalsIgnoreAsciiCase( aRFullMediaType );
84 return bRet;
87 // XTransferable
88 //----------------------------------------------------------------------------
90 Any SAL_CALL DlgEdTransferableImpl::getTransferData( const DataFlavor& rFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException)
92 const SolarMutexGuard aGuard;
94 if ( !isDataFlavorSupported( rFlavor ) )
95 throw UnsupportedFlavorException();
97 Any aData;
99 for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
101 if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
103 aData = m_SeqData[i];
104 break;
108 return aData;
111 //----------------------------------------------------------------------------
113 Sequence< DataFlavor > SAL_CALL DlgEdTransferableImpl::getTransferDataFlavors( ) throw(RuntimeException)
115 const SolarMutexGuard aGuard;
117 return m_SeqFlavors;
120 //----------------------------------------------------------------------------
122 sal_Bool SAL_CALL DlgEdTransferableImpl::isDataFlavorSupported( const DataFlavor& rFlavor ) throw(RuntimeException)
124 const SolarMutexGuard aGuard;
126 sal_Bool bRet = sal_False;
128 for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
130 if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
132 bRet = sal_True;
133 break;
137 return bRet;
140 // XClipboardOwner
141 //----------------------------------------------------------------------------
143 void SAL_CALL DlgEdTransferableImpl::lostOwnership( const Reference< XClipboard >&, const Reference< XTransferable >& ) throw(RuntimeException)
145 const SolarMutexGuard aGuard;
147 m_SeqFlavors = Sequence< DataFlavor >();
148 m_SeqData = Sequence< Any >();
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */