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