1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: JoinExchange.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBAUI_JOINEXCHANGE_HXX
34 #include "JoinExchange.hxx"
36 #ifndef _SOT_FORMATS_HXX
37 #include <sot/formats.hxx>
39 #ifndef _SVX_DBEXCH_HRC
40 #include <svx/dbexch.hrc>
42 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
43 #include <cppuhelper/typeprovider.hxx>
45 #ifndef _SOT_FORMATS_HXX
46 #include <sot/formats.hxx>
51 using namespace ::com::sun::star::uno
;
52 using namespace ::com::sun::star::util
;
53 using namespace ::com::sun::star::lang
;
54 using namespace ::com::sun::star::datatransfer
;
56 String
OJoinExchObj::m_sJoinFormat
;
57 //==================================================================
59 //==================================================================
60 DBG_NAME(OJoinExchObj
)
61 //------------------------------------------------------------------------
62 OJoinExchObj::OJoinExchObj(const OJoinExchangeData
& jxdSource
,sal_Bool _bFirstEntry
)
63 :m_bFirstEntry(_bFirstEntry
)
64 ,m_jxdSourceDescription(jxdSource
)
65 ,m_pDragListener(NULL
)
67 DBG_CTOR(OJoinExchObj
,NULL
);
68 // Verfuegbare Typen in Liste einfuegen
71 //------------------------------------------------------------------------
72 OJoinExchObj::~OJoinExchObj()
74 DBG_DTOR(OJoinExchObj
,NULL
);
77 //------------------------------------------------------------------------
78 void OJoinExchObj::StartDrag( Window
* _pWindow
, sal_Int8 _nDragSourceActions
, IDragTransferableListener
* _pListener
)
80 m_pDragListener
= _pListener
;
81 TransferableHelper::StartDrag(_pWindow
, _nDragSourceActions
);
84 //------------------------------------------------------------------------
85 void OJoinExchObj::DragFinished( sal_Int8
/*nDropAction*/ )
88 m_pDragListener
->dragFinished();
89 m_pDragListener
= NULL
;
92 //------------------------------------------------------------------------
93 sal_Bool
OJoinExchObj::isFormatAvailable( const DataFlavorExVector
& _rFormats
,SotFormatStringId _nSlotID
)
95 DataFlavorExVector::const_iterator aCheckEnd
= _rFormats
.end();
96 for ( DataFlavorExVector::const_iterator aCheck
= _rFormats
.begin();
101 if ( _nSlotID
== aCheck
->mnSotId
)
107 //------------------------------------------------------------------------
108 OJoinExchangeData
OJoinExchObj::GetSourceDescription(const Reference
< XTransferable
>& _rxObject
)
110 OJoinExchangeData aReturn
;
111 Reference
< XUnoTunnel
> xTunnel(_rxObject
, UNO_QUERY
);
114 OJoinExchObj
* pImplementation
= reinterpret_cast<OJoinExchObj
*>(xTunnel
->getSomething(getUnoTunnelImplementationId()));
116 aReturn
= pImplementation
->m_jxdSourceDescription
;
121 //------------------------------------------------------------------------
122 Sequence
< sal_Int8
> OJoinExchObj::getUnoTunnelImplementationId()
124 static ::cppu::OImplementationId
* pId
= 0;
127 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
130 static ::cppu::OImplementationId aId
;
134 return pId
->getImplementationId();
137 //------------------------------------------------------------------------
138 sal_Int64 SAL_CALL
OJoinExchObj::getSomething( const Sequence
< sal_Int8
>& _rIdentifier
) throw(RuntimeException
)
140 if (_rIdentifier
.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), _rIdentifier
.getConstArray(), 16 ) )
141 return reinterpret_cast<sal_Int64
>(this);
146 //------------------------------------------------------------------------
147 void OJoinExchObj::AddSupportedFormats()
149 AddFormat( SOT_FORMATSTR_ID_SBA_JOIN
);
151 AddFormat( SOT_FORMATSTR_ID_SBA_TABID
);
154 //------------------------------------------------------------------------
155 sal_Bool
OJoinExchObj::GetData( const ::com::sun::star::datatransfer::DataFlavor
& rFlavor
)
157 sal_uInt32 nFormat
= SotExchange::GetFormat(rFlavor
);
158 if ( SOT_FORMATSTR_ID_SBA_JOIN
== nFormat
)
160 // we don't really copy our data, the instances using us have to call GetSourceDescription ....
161 // if, one day, we have a _lot_ of time, this hack should be removed ....
167 //------------------------------------------------------------------------
168 Any SAL_CALL
OJoinExchObj::queryInterface( const Type
& _rType
) throw(RuntimeException
)
170 Any aReturn
= TransferableHelper::queryInterface(_rType
);
171 if (!aReturn
.hasValue())
172 aReturn
= OJoinExchObj_Base::queryInterface(_rType
);
176 //------------------------------------------------------------------------
177 void SAL_CALL
OJoinExchObj::acquire( ) throw()
179 TransferableHelper::acquire( );
182 //------------------------------------------------------------------------
183 void SAL_CALL
OJoinExchObj::release( ) throw()
185 TransferableHelper::release( );