merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / querydesign / JoinExchange.cxx
blobb7b9c35582bb4ae7cd6c50bddca206673f86eacb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: JoinExchange.cxx,v $
10 * $Revision: 1.12 $
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"
35 #endif
36 #ifndef _SOT_FORMATS_HXX
37 #include <sot/formats.hxx>
38 #endif
39 #ifndef _SVX_DBEXCH_HRC
40 #include <svx/dbexch.hrc>
41 #endif
42 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
43 #include <cppuhelper/typeprovider.hxx>
44 #endif
45 #ifndef _SOT_FORMATS_HXX
46 #include <sot/formats.hxx>
47 #endif
49 namespace dbaui
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 //==================================================================
58 // class OJoinExchObj
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*/ )
87 if (m_pDragListener)
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();
97 aCheck != aCheckEnd;
98 ++aCheck
101 if ( _nSlotID == aCheck->mnSotId )
102 return sal_True;
104 return sal_False;
107 //------------------------------------------------------------------------
108 OJoinExchangeData OJoinExchObj::GetSourceDescription(const Reference< XTransferable >& _rxObject)
110 OJoinExchangeData aReturn;
111 Reference< XUnoTunnel > xTunnel(_rxObject, UNO_QUERY);
112 if (xTunnel.is())
114 OJoinExchObj* pImplementation = reinterpret_cast<OJoinExchObj*>(xTunnel->getSomething(getUnoTunnelImplementationId()));
115 if (pImplementation)
116 aReturn = pImplementation->m_jxdSourceDescription;
118 return aReturn;
121 //------------------------------------------------------------------------
122 Sequence< sal_Int8 > OJoinExchObj::getUnoTunnelImplementationId()
124 static ::cppu::OImplementationId * pId = 0;
125 if (! pId)
127 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
128 if (! pId)
130 static ::cppu::OImplementationId aId;
131 pId = &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);
143 return 0;
146 //------------------------------------------------------------------------
147 void OJoinExchObj::AddSupportedFormats()
149 AddFormat( SOT_FORMATSTR_ID_SBA_JOIN );
150 if ( m_bFirstEntry )
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 )
159 // this is a HACK
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 ....
162 return sal_True;
164 return sal_False;
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);
173 return aReturn;
176 //------------------------------------------------------------------------
177 void SAL_CALL OJoinExchObj::acquire( ) throw()
179 TransferableHelper::acquire( );
182 //------------------------------------------------------------------------
183 void SAL_CALL OJoinExchObj::release( ) throw()
185 TransferableHelper::release( );
189 } // namespace dbaui