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 : String OJoinExchObj::m_sJoinFormat;
32 : //==================================================================
33 : // class OJoinExchObj
34 : //==================================================================
35 : DBG_NAME(OJoinExchObj)
36 : //------------------------------------------------------------------------
37 0 : OJoinExchObj::OJoinExchObj(const OJoinExchangeData& jxdSource,sal_Bool _bFirstEntry)
38 : :m_bFirstEntry(_bFirstEntry)
39 : ,m_jxdSourceDescription(jxdSource)
40 0 : ,m_pDragListener(NULL)
41 : {
42 : DBG_CTOR(OJoinExchObj,NULL);
43 : // add available types to list
44 0 : }
45 :
46 : //------------------------------------------------------------------------
47 0 : OJoinExchObj::~OJoinExchObj()
48 : {
49 : DBG_DTOR(OJoinExchObj,NULL);
50 0 : }
51 :
52 : //------------------------------------------------------------------------
53 0 : void OJoinExchObj::StartDrag( Window* _pWindow, sal_Int8 _nDragSourceActions, IDragTransferableListener* _pListener )
54 : {
55 0 : m_pDragListener = _pListener;
56 0 : TransferableHelper::StartDrag(_pWindow, _nDragSourceActions);
57 0 : }
58 :
59 : //------------------------------------------------------------------------
60 0 : void OJoinExchObj::DragFinished( sal_Int8 /*nDropAction*/ )
61 : {
62 0 : if (m_pDragListener)
63 0 : m_pDragListener->dragFinished();
64 0 : m_pDragListener = NULL;
65 0 : }
66 :
67 : //------------------------------------------------------------------------
68 0 : sal_Bool OJoinExchObj::isFormatAvailable( const DataFlavorExVector& _rFormats ,SotFormatStringId _nSlotID)
69 : {
70 0 : DataFlavorExVector::const_iterator aCheckEnd = _rFormats.end();
71 0 : for ( DataFlavorExVector::const_iterator aCheck = _rFormats.begin();
72 : aCheck != aCheckEnd;
73 : ++aCheck
74 : )
75 : {
76 0 : if ( _nSlotID == aCheck->mnSotId )
77 0 : return sal_True;
78 : }
79 0 : return sal_False;
80 : }
81 :
82 : //------------------------------------------------------------------------
83 0 : OJoinExchangeData OJoinExchObj::GetSourceDescription(const Reference< XTransferable >& _rxObject)
84 : {
85 0 : OJoinExchangeData aReturn;
86 0 : Reference< XUnoTunnel > xTunnel(_rxObject, UNO_QUERY);
87 0 : if (xTunnel.is())
88 : {
89 0 : OJoinExchObj* pImplementation = reinterpret_cast<OJoinExchObj*>(xTunnel->getSomething(getUnoTunnelImplementationId()));
90 0 : if (pImplementation)
91 0 : aReturn = pImplementation->m_jxdSourceDescription;
92 : }
93 0 : return aReturn;
94 : }
95 :
96 : //------------------------------------------------------------------------
97 0 : Sequence< sal_Int8 > OJoinExchObj::getUnoTunnelImplementationId()
98 : {
99 : static ::cppu::OImplementationId * pId = 0;
100 0 : if (! pId)
101 : {
102 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
103 0 : if (! pId)
104 : {
105 0 : static ::cppu::OImplementationId aId;
106 0 : pId = &aId;
107 0 : }
108 : }
109 0 : return pId->getImplementationId();
110 : }
111 :
112 : //------------------------------------------------------------------------
113 0 : sal_Int64 SAL_CALL OJoinExchObj::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException)
114 : {
115 0 : if (_rIdentifier.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ) )
116 0 : return reinterpret_cast<sal_Int64>(this);
117 :
118 0 : return 0;
119 : }
120 :
121 : //------------------------------------------------------------------------
122 0 : void OJoinExchObj::AddSupportedFormats()
123 : {
124 0 : AddFormat( SOT_FORMATSTR_ID_SBA_JOIN );
125 0 : if ( m_bFirstEntry )
126 0 : AddFormat( SOT_FORMATSTR_ID_SBA_TABID );
127 0 : }
128 :
129 : //------------------------------------------------------------------------
130 0 : sal_Bool OJoinExchObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
131 : {
132 0 : sal_uInt32 nFormat = SotExchange::GetFormat(rFlavor);
133 0 : if ( SOT_FORMATSTR_ID_SBA_JOIN == nFormat )
134 : // this is a HACK
135 : // we don't really copy our data, the instances using us have to call GetSourceDescription ....
136 : // if, one day, we have a _lot_ of time, this hack should be removed ....
137 0 : return sal_True;
138 :
139 0 : return sal_False;
140 : }
141 :
142 : //------------------------------------------------------------------------
143 0 : Any SAL_CALL OJoinExchObj::queryInterface( const Type& _rType ) throw(RuntimeException)
144 : {
145 0 : Any aReturn = TransferableHelper::queryInterface(_rType);
146 0 : if (!aReturn.hasValue())
147 0 : aReturn = OJoinExchObj_Base::queryInterface(_rType);
148 0 : return aReturn;
149 : }
150 :
151 : //------------------------------------------------------------------------
152 0 : void SAL_CALL OJoinExchObj::acquire( ) throw()
153 : {
154 0 : TransferableHelper::acquire( );
155 0 : }
156 :
157 : //------------------------------------------------------------------------
158 0 : void SAL_CALL OJoinExchObj::release( ) throw()
159 : {
160 0 : TransferableHelper::release( );
161 0 : }
162 :
163 :
164 0 : } // namespace dbaui
165 :
166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|