1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "JoinExchange.hxx"
21 #include <sot/formats.hxx>
22 #include <cppuhelper/typeprovider.hxx>
26 using namespace ::com::sun::star::uno
;
27 using namespace ::com::sun::star::util
;
28 using namespace ::com::sun::star::lang
;
29 using namespace ::com::sun::star::datatransfer
;
31 OUString
OJoinExchObj::m_sJoinFormat
;
34 OJoinExchObj::OJoinExchObj(const OJoinExchangeData
& jxdSource
,bool _bFirstEntry
)
35 :m_bFirstEntry(_bFirstEntry
)
36 ,m_jxdSourceDescription(jxdSource
)
37 ,m_pDragListener(NULL
)
39 // add available types to list
42 OJoinExchObj::~OJoinExchObj()
46 void OJoinExchObj::StartDrag( vcl::Window
* _pWindow
, sal_Int8 _nDragSourceActions
, IDragTransferableListener
* _pListener
)
48 m_pDragListener
= _pListener
;
49 TransferableHelper::StartDrag(_pWindow
, _nDragSourceActions
);
52 void OJoinExchObj::DragFinished( sal_Int8
/*nDropAction*/ )
55 m_pDragListener
->dragFinished();
56 m_pDragListener
= NULL
;
59 bool OJoinExchObj::isFormatAvailable( const DataFlavorExVector
& _rFormats
,SotClipboardFormatId _nSlotID
)
61 DataFlavorExVector::const_iterator aCheckEnd
= _rFormats
.end();
62 for ( DataFlavorExVector::const_iterator aCheck
= _rFormats
.begin();
67 if ( _nSlotID
== aCheck
->mnSotId
)
73 OJoinExchangeData
OJoinExchObj::GetSourceDescription(const Reference
< XTransferable
>& _rxObject
)
75 OJoinExchangeData aReturn
;
76 Reference
< XUnoTunnel
> xTunnel(_rxObject
, UNO_QUERY
);
79 OJoinExchObj
* pImplementation
= reinterpret_cast<OJoinExchObj
*>(xTunnel
->getSomething(getUnoTunnelImplementationId()));
81 aReturn
= pImplementation
->m_jxdSourceDescription
;
86 Sequence
< sal_Int8
> OJoinExchObj::getUnoTunnelImplementationId()
88 static ::cppu::OImplementationId
* pId
= 0;
91 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
94 static ::cppu::OImplementationId aId
;
98 return pId
->getImplementationId();
101 sal_Int64 SAL_CALL
OJoinExchObj::getSomething( const Sequence
< sal_Int8
>& _rIdentifier
) throw(RuntimeException
, std::exception
)
103 if (_rIdentifier
.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), _rIdentifier
.getConstArray(), 16 ) )
104 return reinterpret_cast<sal_Int64
>(this);
109 void OJoinExchObj::AddSupportedFormats()
111 AddFormat( SotClipboardFormatId::SBA_JOIN
);
113 AddFormat( SotClipboardFormatId::SBA_TABID
);
116 bool OJoinExchObj::GetData( const css::datatransfer::DataFlavor
& rFlavor
, const OUString
& /*rDestDoc*/ )
118 SotClipboardFormatId nFormat
= SotExchange::GetFormat(rFlavor
);
119 if ( SotClipboardFormatId::SBA_JOIN
== nFormat
)
121 // we don't really copy our data, the instances using us have to call GetSourceDescription ....
122 // if, one day, we have a _lot_ of time, this hack should be removed ....
128 Any SAL_CALL
OJoinExchObj::queryInterface( const Type
& _rType
) throw(RuntimeException
, std::exception
)
130 Any aReturn
= TransferableHelper::queryInterface(_rType
);
131 if (!aReturn
.hasValue())
132 aReturn
= OJoinExchObj_Base::queryInterface(_rType
);
136 void SAL_CALL
OJoinExchObj::acquire( ) throw()
138 TransferableHelper::acquire( );
141 void SAL_CALL
OJoinExchObj::release( ) throw()
143 TransferableHelper::release( );
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */