Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / ui / querydesign / JoinExchange.cxx
blob0cc4c779c3c4d00b5a647d92597472029bd7b785
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "JoinExchange.hxx"
21 #include <sot/formats.hxx>
22 #include <cppuhelper/typeprovider.hxx>
24 namespace dbaui
26 using namespace ::com::sun::star::uno;
27 using namespace ::com::sun::star::util;
28 using namespace ::com::sun::star::lang;
29 using namespace ::com::sun::star::datatransfer;
31 OUString OJoinExchObj::m_sJoinFormat;
33 // class OJoinExchObj
34 OJoinExchObj::OJoinExchObj(const OJoinExchangeData& jxdSource,bool _bFirstEntry)
35 :m_bFirstEntry(_bFirstEntry)
36 ,m_jxdSourceDescription(jxdSource)
37 ,m_pDragListener(NULL)
39 // add available types to list
42 OJoinExchObj::~OJoinExchObj()
46 void OJoinExchObj::StartDrag( vcl::Window* _pWindow, sal_Int8 _nDragSourceActions, IDragTransferableListener* _pListener )
48 m_pDragListener = _pListener;
49 TransferableHelper::StartDrag(_pWindow, _nDragSourceActions);
52 void OJoinExchObj::DragFinished( sal_Int8 /*nDropAction*/ )
54 if (m_pDragListener)
55 m_pDragListener->dragFinished();
56 m_pDragListener = NULL;
59 bool OJoinExchObj::isFormatAvailable( const DataFlavorExVector& _rFormats ,SotClipboardFormatId _nSlotID)
61 DataFlavorExVector::const_iterator aCheckEnd = _rFormats.end();
62 for ( DataFlavorExVector::const_iterator aCheck = _rFormats.begin();
63 aCheck != aCheckEnd;
64 ++aCheck
67 if ( _nSlotID == aCheck->mnSotId )
68 return true;
70 return false;
73 OJoinExchangeData OJoinExchObj::GetSourceDescription(const Reference< XTransferable >& _rxObject)
75 OJoinExchangeData aReturn;
76 Reference< XUnoTunnel > xTunnel(_rxObject, UNO_QUERY);
77 if (xTunnel.is())
79 OJoinExchObj* pImplementation = reinterpret_cast<OJoinExchObj*>(xTunnel->getSomething(getUnoTunnelImplementationId()));
80 if (pImplementation)
81 aReturn = pImplementation->m_jxdSourceDescription;
83 return aReturn;
86 Sequence< sal_Int8 > OJoinExchObj::getUnoTunnelImplementationId()
88 static ::cppu::OImplementationId * pId = 0;
89 if (! pId)
91 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
92 if (! pId)
94 static ::cppu::OImplementationId aId;
95 pId = &aId;
98 return pId->getImplementationId();
101 sal_Int64 SAL_CALL OJoinExchObj::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException, std::exception)
103 if (_rIdentifier.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ) )
104 return reinterpret_cast<sal_Int64>(this);
106 return 0;
109 void OJoinExchObj::AddSupportedFormats()
111 AddFormat( SotClipboardFormatId::SBA_JOIN );
112 if ( m_bFirstEntry )
113 AddFormat( SotClipboardFormatId::SBA_TABID );
116 bool OJoinExchObj::GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ )
118 SotClipboardFormatId nFormat = SotExchange::GetFormat(rFlavor);
119 if ( SotClipboardFormatId::SBA_JOIN == nFormat )
120 // this is a HACK
121 // we don't really copy our data, the instances using us have to call GetSourceDescription ....
122 // if, one day, we have a _lot_ of time, this hack should be removed ....
123 return true;
125 return false;
128 Any SAL_CALL OJoinExchObj::queryInterface( const Type& _rType ) throw(RuntimeException, std::exception)
130 Any aReturn = TransferableHelper::queryInterface(_rType);
131 if (!aReturn.hasValue())
132 aReturn = OJoinExchObj_Base::queryInterface(_rType);
133 return aReturn;
136 void SAL_CALL OJoinExchObj::acquire( ) throw()
138 TransferableHelper::acquire( );
141 void SAL_CALL OJoinExchObj::release( ) throw()
143 TransferableHelper::release( );
146 } // namespace dbaui
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */