Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "JoinExchange.hxx"
21 : #include <sot/formats.hxx>
22 : #include <cppuhelper/typeprovider.hxx>
23 :
24 : namespace dbaui
25 : {
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;
30 :
31 0 : OUString OJoinExchObj::m_sJoinFormat;
32 :
33 : // class OJoinExchObj
34 0 : OJoinExchObj::OJoinExchObj(const OJoinExchangeData& jxdSource,sal_Bool _bFirstEntry)
35 : :m_bFirstEntry(_bFirstEntry)
36 : ,m_jxdSourceDescription(jxdSource)
37 0 : ,m_pDragListener(NULL)
38 : {
39 : // add available types to list
40 0 : }
41 :
42 0 : OJoinExchObj::~OJoinExchObj()
43 : {
44 0 : }
45 :
46 0 : void OJoinExchObj::StartDrag( Window* _pWindow, sal_Int8 _nDragSourceActions, IDragTransferableListener* _pListener )
47 : {
48 0 : m_pDragListener = _pListener;
49 0 : TransferableHelper::StartDrag(_pWindow, _nDragSourceActions);
50 0 : }
51 :
52 0 : void OJoinExchObj::DragFinished( sal_Int8 /*nDropAction*/ )
53 : {
54 0 : if (m_pDragListener)
55 0 : m_pDragListener->dragFinished();
56 0 : m_pDragListener = NULL;
57 0 : }
58 :
59 0 : sal_Bool OJoinExchObj::isFormatAvailable( const DataFlavorExVector& _rFormats ,SotFormatStringId _nSlotID)
60 : {
61 0 : DataFlavorExVector::const_iterator aCheckEnd = _rFormats.end();
62 0 : for ( DataFlavorExVector::const_iterator aCheck = _rFormats.begin();
63 : aCheck != aCheckEnd;
64 : ++aCheck
65 : )
66 : {
67 0 : if ( _nSlotID == aCheck->mnSotId )
68 0 : return sal_True;
69 : }
70 0 : return sal_False;
71 : }
72 :
73 0 : OJoinExchangeData OJoinExchObj::GetSourceDescription(const Reference< XTransferable >& _rxObject)
74 : {
75 0 : OJoinExchangeData aReturn;
76 0 : Reference< XUnoTunnel > xTunnel(_rxObject, UNO_QUERY);
77 0 : if (xTunnel.is())
78 : {
79 0 : OJoinExchObj* pImplementation = reinterpret_cast<OJoinExchObj*>(xTunnel->getSomething(getUnoTunnelImplementationId()));
80 0 : if (pImplementation)
81 0 : aReturn = pImplementation->m_jxdSourceDescription;
82 : }
83 0 : return aReturn;
84 : }
85 :
86 0 : Sequence< sal_Int8 > OJoinExchObj::getUnoTunnelImplementationId()
87 : {
88 : static ::cppu::OImplementationId * pId = 0;
89 0 : if (! pId)
90 : {
91 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
92 0 : if (! pId)
93 : {
94 0 : static ::cppu::OImplementationId aId;
95 0 : pId = &aId;
96 0 : }
97 : }
98 0 : return pId->getImplementationId();
99 : }
100 :
101 0 : sal_Int64 SAL_CALL OJoinExchObj::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException, std::exception)
102 : {
103 0 : if (_rIdentifier.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ) )
104 0 : return reinterpret_cast<sal_Int64>(this);
105 :
106 0 : return 0;
107 : }
108 :
109 0 : void OJoinExchObj::AddSupportedFormats()
110 : {
111 0 : AddFormat( SOT_FORMATSTR_ID_SBA_JOIN );
112 0 : if ( m_bFirstEntry )
113 0 : AddFormat( SOT_FORMATSTR_ID_SBA_TABID );
114 0 : }
115 :
116 0 : bool OJoinExchObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
117 : {
118 0 : sal_uInt32 nFormat = SotExchange::GetFormat(rFlavor);
119 0 : if ( SOT_FORMATSTR_ID_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 0 : return true;
124 :
125 0 : return false;
126 : }
127 :
128 0 : Any SAL_CALL OJoinExchObj::queryInterface( const Type& _rType ) throw(RuntimeException, std::exception)
129 : {
130 0 : Any aReturn = TransferableHelper::queryInterface(_rType);
131 0 : if (!aReturn.hasValue())
132 0 : aReturn = OJoinExchObj_Base::queryInterface(_rType);
133 0 : return aReturn;
134 : }
135 :
136 0 : void SAL_CALL OJoinExchObj::acquire( ) throw()
137 : {
138 0 : TransferableHelper::acquire( );
139 0 : }
140 :
141 0 : void SAL_CALL OJoinExchObj::release( ) throw()
142 : {
143 0 : TransferableHelper::release( );
144 0 : }
145 :
146 0 : } // namespace dbaui
147 :
148 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|