1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef DBAUI_JOINEXCHANGE_HXX
27cdf0e10cSrcweir #include "JoinExchange.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _SOT_FORMATS_HXX
30cdf0e10cSrcweir #include <sot/formats.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _SVX_DBEXCH_HRC
33cdf0e10cSrcweir #include <svx/dbexch.hrc>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
36cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef _SOT_FORMATS_HXX
39cdf0e10cSrcweir #include <sot/formats.hxx>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace dbaui
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
45cdf0e10cSrcweir 	using namespace ::com::sun::star::util;
46cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
47cdf0e10cSrcweir 	using namespace ::com::sun::star::datatransfer;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	String OJoinExchObj::m_sJoinFormat;
50cdf0e10cSrcweir 	//==================================================================
51cdf0e10cSrcweir 	// class OJoinExchObj
52cdf0e10cSrcweir 	//==================================================================
DBG_NAME(OJoinExchObj)53cdf0e10cSrcweir 	DBG_NAME(OJoinExchObj)
54cdf0e10cSrcweir 	//------------------------------------------------------------------------
55cdf0e10cSrcweir 	OJoinExchObj::OJoinExchObj(const OJoinExchangeData& jxdSource,sal_Bool _bFirstEntry)
56cdf0e10cSrcweir         :m_bFirstEntry(_bFirstEntry)
57cdf0e10cSrcweir 		,m_jxdSourceDescription(jxdSource)
58cdf0e10cSrcweir 		,m_pDragListener(NULL)
59cdf0e10cSrcweir 	{
60cdf0e10cSrcweir 		DBG_CTOR(OJoinExchObj,NULL);
61cdf0e10cSrcweir 		// Verfuegbare Typen in Liste einfuegen
62cdf0e10cSrcweir 	}
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	//------------------------------------------------------------------------
~OJoinExchObj()65cdf0e10cSrcweir 	OJoinExchObj::~OJoinExchObj()
66cdf0e10cSrcweir 	{
67cdf0e10cSrcweir 		DBG_DTOR(OJoinExchObj,NULL);
68cdf0e10cSrcweir 	}
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	//------------------------------------------------------------------------
StartDrag(Window * _pWindow,sal_Int8 _nDragSourceActions,IDragTransferableListener * _pListener)71cdf0e10cSrcweir 	void OJoinExchObj::StartDrag( Window* _pWindow, sal_Int8 _nDragSourceActions, IDragTransferableListener* _pListener )
72cdf0e10cSrcweir 	{
73cdf0e10cSrcweir 		m_pDragListener = _pListener;
74cdf0e10cSrcweir 		TransferableHelper::StartDrag(_pWindow, _nDragSourceActions);
75cdf0e10cSrcweir 	}
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	//------------------------------------------------------------------------
DragFinished(sal_Int8)78cdf0e10cSrcweir 	void OJoinExchObj::DragFinished( sal_Int8 /*nDropAction*/ )
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		if (m_pDragListener)
81cdf0e10cSrcweir 			m_pDragListener->dragFinished();
82cdf0e10cSrcweir 		m_pDragListener = NULL;
83cdf0e10cSrcweir 	}
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	//------------------------------------------------------------------------
isFormatAvailable(const DataFlavorExVector & _rFormats,SotFormatStringId _nSlotID)86cdf0e10cSrcweir 	sal_Bool OJoinExchObj::isFormatAvailable( const DataFlavorExVector& _rFormats ,SotFormatStringId _nSlotID)
87cdf0e10cSrcweir 	{
88cdf0e10cSrcweir         DataFlavorExVector::const_iterator aCheckEnd = _rFormats.end();
89cdf0e10cSrcweir 		for	(	DataFlavorExVector::const_iterator aCheck = _rFormats.begin();
90cdf0e10cSrcweir 				aCheck != aCheckEnd;
91cdf0e10cSrcweir 				++aCheck
92cdf0e10cSrcweir 			)
93cdf0e10cSrcweir 		{
94cdf0e10cSrcweir 			if ( _nSlotID == aCheck->mnSotId )
95cdf0e10cSrcweir 				return sal_True;
96cdf0e10cSrcweir 		}
97cdf0e10cSrcweir 		return sal_False;
98cdf0e10cSrcweir 	}
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	//------------------------------------------------------------------------
GetSourceDescription(const Reference<XTransferable> & _rxObject)101cdf0e10cSrcweir 	OJoinExchangeData OJoinExchObj::GetSourceDescription(const Reference< XTransferable >& _rxObject)
102cdf0e10cSrcweir 	{
103cdf0e10cSrcweir 		OJoinExchangeData aReturn;
104cdf0e10cSrcweir 		Reference< XUnoTunnel > xTunnel(_rxObject, UNO_QUERY);
105cdf0e10cSrcweir 		if (xTunnel.is())
106cdf0e10cSrcweir 		{
107cdf0e10cSrcweir 			OJoinExchObj* pImplementation = reinterpret_cast<OJoinExchObj*>(xTunnel->getSomething(getUnoTunnelImplementationId()));
108cdf0e10cSrcweir 			if (pImplementation)
109cdf0e10cSrcweir 				aReturn = pImplementation->m_jxdSourceDescription;
110cdf0e10cSrcweir 		}
111cdf0e10cSrcweir 		return aReturn;
112cdf0e10cSrcweir 	}
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	//------------------------------------------------------------------------
getUnoTunnelImplementationId()115cdf0e10cSrcweir 	Sequence< sal_Int8 > OJoinExchObj::getUnoTunnelImplementationId()
116cdf0e10cSrcweir 	{
117cdf0e10cSrcweir 		static ::cppu::OImplementationId * pId = 0;
118cdf0e10cSrcweir 		if (! pId)
119cdf0e10cSrcweir 		{
120cdf0e10cSrcweir 			::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
121cdf0e10cSrcweir 			if (! pId)
122cdf0e10cSrcweir 			{
123cdf0e10cSrcweir 				static ::cppu::OImplementationId aId;
124cdf0e10cSrcweir 				pId = &aId;
125cdf0e10cSrcweir 			}
126cdf0e10cSrcweir 		}
127cdf0e10cSrcweir 		return pId->getImplementationId();
128cdf0e10cSrcweir 	}
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	//------------------------------------------------------------------------
getSomething(const Sequence<sal_Int8> & _rIdentifier)131cdf0e10cSrcweir     sal_Int64 SAL_CALL OJoinExchObj::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException)
132cdf0e10cSrcweir 	{
133cdf0e10cSrcweir 		if (_rIdentifier.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(),  _rIdentifier.getConstArray(), 16 ) )
134cdf0e10cSrcweir 			return reinterpret_cast<sal_Int64>(this);
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 		return 0;
137cdf0e10cSrcweir 	}
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	//------------------------------------------------------------------------
AddSupportedFormats()140cdf0e10cSrcweir 	void OJoinExchObj::AddSupportedFormats()
141cdf0e10cSrcweir 	{
142cdf0e10cSrcweir 		AddFormat( SOT_FORMATSTR_ID_SBA_JOIN );
143cdf0e10cSrcweir 		if ( m_bFirstEntry )
144cdf0e10cSrcweir 			AddFormat( SOT_FORMATSTR_ID_SBA_TABID );
145cdf0e10cSrcweir 	}
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	//------------------------------------------------------------------------
GetData(const::com::sun::star::datatransfer::DataFlavor & rFlavor)148cdf0e10cSrcweir 	sal_Bool OJoinExchObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
149cdf0e10cSrcweir 	{
150cdf0e10cSrcweir 		sal_uInt32 nFormat = SotExchange::GetFormat(rFlavor);
151cdf0e10cSrcweir 		if ( SOT_FORMATSTR_ID_SBA_JOIN == nFormat )
152cdf0e10cSrcweir 			// this is a HACK
153cdf0e10cSrcweir 			// we don't really copy our data, the instances using us have to call GetSourceDescription ....
154cdf0e10cSrcweir 			// if, one day, we have a _lot_ of time, this hack should be removed ....
155cdf0e10cSrcweir 			return sal_True;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		return sal_False;
158cdf0e10cSrcweir 	}
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	//------------------------------------------------------------------------
queryInterface(const Type & _rType)161cdf0e10cSrcweir 	Any SAL_CALL OJoinExchObj::queryInterface( const Type& _rType ) throw(RuntimeException)
162cdf0e10cSrcweir 	{
163cdf0e10cSrcweir 		Any aReturn = TransferableHelper::queryInterface(_rType);
164cdf0e10cSrcweir 		if (!aReturn.hasValue())
165cdf0e10cSrcweir 			aReturn = OJoinExchObj_Base::queryInterface(_rType);
166cdf0e10cSrcweir 		return aReturn;
167cdf0e10cSrcweir 	}
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	//------------------------------------------------------------------------
acquire()170cdf0e10cSrcweir 	void SAL_CALL OJoinExchObj::acquire(  ) throw()
171cdf0e10cSrcweir 	{
172cdf0e10cSrcweir 		TransferableHelper::acquire( );
173cdf0e10cSrcweir 	}
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	//------------------------------------------------------------------------
release()176cdf0e10cSrcweir 	void SAL_CALL OJoinExchObj::release(  ) throw()
177cdf0e10cSrcweir 	{
178cdf0e10cSrcweir 		TransferableHelper::release( );
179cdf0e10cSrcweir 	}
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 
182cdf0e10cSrcweir }	// namespace dbaui
183