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