xref: /aoo42x/main/svx/source/form/fmexch.cxx (revision f6e50924)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include "fmexch.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <sot/storage.hxx>
29cdf0e10cSrcweir #include <svl/itempool.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef _SVX_DBEXCH_HRC
32cdf0e10cSrcweir #include <svx/dbexch.hrc>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include <sot/formats.hxx>
35cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
36cdf0e10cSrcweir #include <tools/diagnose_ex.h>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #define _SVSTDARR_ULONGS
39cdf0e10cSrcweir #include <svl/svstdarr.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir //........................................................................
42cdf0e10cSrcweir namespace svxform
43cdf0e10cSrcweir {
44cdf0e10cSrcweir //........................................................................
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
47cdf0e10cSrcweir 	using namespace ::com::sun::star::datatransfer;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	//====================================================================
50cdf0e10cSrcweir 	//= OLocalExchange
51cdf0e10cSrcweir 	//====================================================================
52cdf0e10cSrcweir 	//--------------------------------------------------------------------
OLocalExchange()53cdf0e10cSrcweir 	OLocalExchange::OLocalExchange( )
54cdf0e10cSrcweir 		:m_bDragging( sal_False )
55cdf0e10cSrcweir 		,m_bClipboardOwner( sal_False )
56cdf0e10cSrcweir 	{
57cdf0e10cSrcweir 	}
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	//--------------------------------------------------------------------
copyToClipboard(Window * _pWindow,const GrantAccess &)60cdf0e10cSrcweir 	void OLocalExchange::copyToClipboard( Window* _pWindow, const GrantAccess& )
61cdf0e10cSrcweir 	{
62cdf0e10cSrcweir 		if ( m_bClipboardOwner )
63cdf0e10cSrcweir 		{	// simulate a lostOwnership to notify parties interested in
64cdf0e10cSrcweir 			if ( m_aClipboardListener.IsSet() )
65cdf0e10cSrcweir 				m_aClipboardListener.Call( this );
66cdf0e10cSrcweir 		}
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 		m_bClipboardOwner = sal_True;
69cdf0e10cSrcweir 		CopyToClipboard( _pWindow );
70cdf0e10cSrcweir 	}
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	//--------------------------------------------------------------------
clear()73cdf0e10cSrcweir 	void OLocalExchange::clear()
74cdf0e10cSrcweir 	{
75cdf0e10cSrcweir 		if ( isClipboardOwner() )
76cdf0e10cSrcweir 		{
77cdf0e10cSrcweir 			try
78cdf0e10cSrcweir 			{
79cdf0e10cSrcweir 				Reference< clipboard::XClipboard > xClipBoard( getOwnClipboard() );
80cdf0e10cSrcweir 				if ( xClipBoard.is() )
81cdf0e10cSrcweir 					xClipBoard->setContents( NULL, NULL );
82cdf0e10cSrcweir 			}
83cdf0e10cSrcweir 			catch( const Exception& )
84cdf0e10cSrcweir 			{
85cdf0e10cSrcweir                 DBG_UNHANDLED_EXCEPTION();
86cdf0e10cSrcweir 			}
87cdf0e10cSrcweir 			m_bClipboardOwner = sal_False;
88cdf0e10cSrcweir 		}
89cdf0e10cSrcweir 	}
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	//--------------------------------------------------------------------
lostOwnership(const Reference<clipboard::XClipboard> & _rxClipboard,const Reference<XTransferable> & _rxTrans)92cdf0e10cSrcweir     void SAL_CALL OLocalExchange::lostOwnership( const Reference< clipboard::XClipboard >& _rxClipboard, const Reference< XTransferable >& _rxTrans ) throw(RuntimeException)
93cdf0e10cSrcweir 	{
94cdf0e10cSrcweir 		TransferableHelper::implCallOwnLostOwnership( _rxClipboard, _rxTrans );
95cdf0e10cSrcweir 		m_bClipboardOwner = sal_False;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 		if ( m_aClipboardListener.IsSet() )
98cdf0e10cSrcweir 			m_aClipboardListener.Call( this );
99cdf0e10cSrcweir 	}
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	//--------------------------------------------------------------------
startDrag(Window * _pWindow,sal_Int8 _nDragSourceActions,const GrantAccess &)102cdf0e10cSrcweir 	void OLocalExchange::startDrag( Window* _pWindow, sal_Int8 _nDragSourceActions, const GrantAccess& )
103cdf0e10cSrcweir 	{
104cdf0e10cSrcweir 		m_bDragging = sal_True;
105cdf0e10cSrcweir 		StartDrag( _pWindow, _nDragSourceActions );
106cdf0e10cSrcweir 	}
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	//--------------------------------------------------------------------
DragFinished(sal_Int8 nDropAction)109cdf0e10cSrcweir 	void OLocalExchange::DragFinished( sal_Int8 nDropAction )
110cdf0e10cSrcweir 	{
111cdf0e10cSrcweir 		TransferableHelper::DragFinished( nDropAction );
112cdf0e10cSrcweir 		m_bDragging = sal_False;
113cdf0e10cSrcweir 	}
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	//--------------------------------------------------------------------
hasFormat(const DataFlavorExVector & _rFormats,sal_uInt32 _nFormatId)116cdf0e10cSrcweir 	sal_Bool OLocalExchange::hasFormat( const DataFlavorExVector& _rFormats, sal_uInt32 _nFormatId )
117cdf0e10cSrcweir 	{
118cdf0e10cSrcweir 		DataFlavorExVector::const_iterator aSearch;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 		for	( aSearch = _rFormats.begin(); aSearch != _rFormats.end(); ++aSearch )
121cdf0e10cSrcweir 			if ( aSearch->mnSotId == _nFormatId )
122cdf0e10cSrcweir 				break;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 		return aSearch != _rFormats.end();
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	//--------------------------------------------------------------------
GetData(const::com::sun::star::datatransfer::DataFlavor &)128cdf0e10cSrcweir 	sal_Bool OLocalExchange::GetData( const ::com::sun::star::datatransfer::DataFlavor& /*_rFlavor*/ )
129cdf0e10cSrcweir 	{
130cdf0e10cSrcweir 		return sal_False;	// do not have any formats by default
131cdf0e10cSrcweir 	}
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	//====================================================================
134cdf0e10cSrcweir 	//= OControlTransferData
135cdf0e10cSrcweir 	//====================================================================
136cdf0e10cSrcweir 	//--------------------------------------------------------------------
OControlTransferData()137cdf0e10cSrcweir 	OControlTransferData::OControlTransferData( )
138cdf0e10cSrcweir 		:m_pFocusEntry( NULL )
139cdf0e10cSrcweir 	{
140cdf0e10cSrcweir 	}
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	//--------------------------------------------------------------------
OControlTransferData(const Reference<XTransferable> & _rxTransferable)143cdf0e10cSrcweir 	OControlTransferData::OControlTransferData( const Reference< XTransferable >& _rxTransferable )
144cdf0e10cSrcweir 		:m_pFocusEntry( NULL )
145cdf0e10cSrcweir 	{
146cdf0e10cSrcweir 		TransferableDataHelper aExchangedData( _rxTransferable );
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 		// try the formats we know
149cdf0e10cSrcweir 		if ( OControlExchange::hasControlPathFormat( aExchangedData.GetDataFlavorExVector() ) )
150cdf0e10cSrcweir 		{	// paths to the controls, relative to a root
151cdf0e10cSrcweir 			Sequence< Any > aControlPathData;
152cdf0e10cSrcweir 			if ( aExchangedData.GetAny( OControlExchange::getControlPathFormatId() ) >>= aControlPathData )
153cdf0e10cSrcweir 			{
154cdf0e10cSrcweir 				DBG_ASSERT( aControlPathData.getLength() >= 2, "OControlTransferData::OControlTransferData: invalid data for the control path format!" );
155cdf0e10cSrcweir 				if ( aControlPathData.getLength() >= 2 )
156cdf0e10cSrcweir 				{
157cdf0e10cSrcweir 					aControlPathData[0] >>= m_xFormsRoot;
158cdf0e10cSrcweir 					aControlPathData[1] >>= m_aControlPaths;
159cdf0e10cSrcweir 				}
160cdf0e10cSrcweir 			}
161cdf0e10cSrcweir 			else
162cdf0e10cSrcweir 			{
163cdf0e10cSrcweir 				DBG_ERROR( "OControlTransferData::OControlTransferData: invalid data for the control path format (2)!" );
164cdf0e10cSrcweir 			}
165cdf0e10cSrcweir 		}
166cdf0e10cSrcweir 		if ( OControlExchange::hasHiddenControlModelsFormat( aExchangedData.GetDataFlavorExVector() ) )
167cdf0e10cSrcweir 		{	// sequence of models of hidden controls
168cdf0e10cSrcweir 			aExchangedData.GetAny( OControlExchange::getHiddenControlModelsFormatId() ) >>= m_aHiddenControlModels;
169cdf0e10cSrcweir 		}
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 		updateFormats( );
172cdf0e10cSrcweir 	}
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	//--------------------------------------------------------------------
lcl_fillDataFlavorEx(SotFormatStringId nId,DataFlavorEx & _rFlavor)175cdf0e10cSrcweir 	static sal_Bool lcl_fillDataFlavorEx( SotFormatStringId nId, DataFlavorEx& _rFlavor )
176cdf0e10cSrcweir 	{
177cdf0e10cSrcweir 		_rFlavor.mnSotId = nId;
178cdf0e10cSrcweir 		return SotExchange::GetFormatDataFlavor( _rFlavor.mnSotId, _rFlavor );
179cdf0e10cSrcweir 	}
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 	//--------------------------------------------------------------------
updateFormats()182cdf0e10cSrcweir 	void OControlTransferData::updateFormats( )
183cdf0e10cSrcweir 	{
184cdf0e10cSrcweir 		m_aCurrentFormats.clear();
185cdf0e10cSrcweir 		m_aCurrentFormats.reserve( 3 );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 		DataFlavorEx aFlavor;
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 		if ( m_aHiddenControlModels.getLength() )
190cdf0e10cSrcweir 		{
191cdf0e10cSrcweir 			if ( lcl_fillDataFlavorEx( OControlExchange::getHiddenControlModelsFormatId(), aFlavor ) )
192cdf0e10cSrcweir 				m_aCurrentFormats.push_back( aFlavor );
193cdf0e10cSrcweir 		}
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 		if ( m_xFormsRoot.is() && m_aControlPaths.getLength() )
196cdf0e10cSrcweir 		{
197cdf0e10cSrcweir 			if ( lcl_fillDataFlavorEx( OControlExchange::getControlPathFormatId(), aFlavor ) )
198cdf0e10cSrcweir 				m_aCurrentFormats.push_back( aFlavor );
199cdf0e10cSrcweir 		}
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 		if ( !m_aSelectedEntries.empty() )
202cdf0e10cSrcweir 		{
203cdf0e10cSrcweir 			if ( lcl_fillDataFlavorEx( OControlExchange::getFieldExchangeFormatId(), aFlavor ) )
204cdf0e10cSrcweir 				m_aCurrentFormats.push_back( aFlavor );
205cdf0e10cSrcweir 		}
206cdf0e10cSrcweir 	}
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	//--------------------------------------------------------------------
onEntryRemoved(SvLBoxEntry * _pEntry)209cdf0e10cSrcweir 	size_t OControlTransferData::onEntryRemoved( SvLBoxEntry* _pEntry )
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir         m_aSelectedEntries.erase( _pEntry );
212cdf0e10cSrcweir         return m_aSelectedEntries.size();
213cdf0e10cSrcweir 	}
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	//--------------------------------------------------------------------
addSelectedEntry(SvLBoxEntry * _pEntry)216cdf0e10cSrcweir 	void OControlTransferData::addSelectedEntry( SvLBoxEntry* _pEntry )
217cdf0e10cSrcweir 	{
218cdf0e10cSrcweir 		m_aSelectedEntries.insert( _pEntry );
219cdf0e10cSrcweir 	}
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 	//--------------------------------------------------------------------
setFocusEntry(SvLBoxEntry * _pFocusEntry)222cdf0e10cSrcweir 	void OControlTransferData::setFocusEntry( SvLBoxEntry* _pFocusEntry )
223cdf0e10cSrcweir 	{
224cdf0e10cSrcweir 		m_pFocusEntry = _pFocusEntry;
225cdf0e10cSrcweir 	}
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	//------------------------------------------------------------------------
addHiddenControlsFormat(const::com::sun::star::uno::Sequence<::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface>> seqInterfaces)228cdf0e10cSrcweir 	void OControlTransferData::addHiddenControlsFormat(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqInterfaces)
229cdf0e10cSrcweir 	{
230cdf0e10cSrcweir 		m_aHiddenControlModels = seqInterfaces;
231cdf0e10cSrcweir 	}
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 	//------------------------------------------------------------------------
buildPathFormat(SvTreeListBox * pTreeBox,SvLBoxEntry * pRoot)234cdf0e10cSrcweir 	void OControlTransferData::buildPathFormat(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot)
235cdf0e10cSrcweir 	{
236cdf0e10cSrcweir 		m_aControlPaths.realloc(0);
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 		sal_Int32 nEntryCount = m_aSelectedEntries.size();
239cdf0e10cSrcweir 		if (nEntryCount == 0)
240cdf0e10cSrcweir 			return;
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 		m_aControlPaths.realloc(nEntryCount);
243cdf0e10cSrcweir 		::com::sun::star::uno::Sequence<sal_uInt32>* pAllPaths = m_aControlPaths.getArray();
244cdf0e10cSrcweir         for (   ListBoxEntrySet::const_iterator loop = m_aSelectedEntries.begin();
245cdf0e10cSrcweir                 loop != m_aSelectedEntries.end();
246cdf0e10cSrcweir                 ++loop, ++pAllPaths
247cdf0e10cSrcweir             )
248cdf0e10cSrcweir 		{
249cdf0e10cSrcweir 			// erst mal sammeln wir den Pfad in einem Array ein
250cdf0e10cSrcweir 			::std::vector< sal_uInt32 > aCurrentPath;
251cdf0e10cSrcweir 			SvLBoxEntry* pCurrentEntry = *loop;
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 			SvLBoxEntry* pLoop = pCurrentEntry;
254cdf0e10cSrcweir 			while (pLoop != pRoot)
255cdf0e10cSrcweir 			{
256cdf0e10cSrcweir 				aCurrentPath.push_back(pLoop->GetChildListPos());
257cdf0e10cSrcweir 				pLoop = pTreeBox->GetParent(pLoop);
258cdf0e10cSrcweir 				DBG_ASSERT((pLoop != NULL) || (pRoot == 0), "OControlTransferData::buildPathFormat: invalid root or entry !");
259cdf0e10cSrcweir 					// pLoop == NULL heisst, dass ich am oberen Ende angelangt bin, dann sollte das Ganze abbrechen, was nur bei pRoot == NULL der Fall sein wird
260cdf0e10cSrcweir 			}
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 			// dann koennen wir ihn in die ::com::sun::star::uno::Sequence uebertragen
263cdf0e10cSrcweir 			Sequence<sal_uInt32>& rCurrentPath = *pAllPaths;
264cdf0e10cSrcweir 			sal_Int32 nDepth = aCurrentPath.size();
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 			rCurrentPath.realloc(nDepth);
267cdf0e10cSrcweir 			sal_uInt32* pSeq = rCurrentPath.getArray();
268cdf0e10cSrcweir 			sal_Int32 j,k;
269cdf0e10cSrcweir 			for (j = nDepth - 1, k = 0; k<nDepth; --j, ++k)
270cdf0e10cSrcweir 				pSeq[j] = aCurrentPath[k];
271cdf0e10cSrcweir 		}
272cdf0e10cSrcweir 	}
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 	//------------------------------------------------------------------------
buildListFromPath(SvTreeListBox * pTreeBox,SvLBoxEntry * pRoot)275cdf0e10cSrcweir 	void OControlTransferData::buildListFromPath(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot)
276cdf0e10cSrcweir 	{
277cdf0e10cSrcweir         ListBoxEntrySet aEmpty;
278cdf0e10cSrcweir 		m_aSelectedEntries.swap( aEmpty );
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 		sal_Int32 nControls = m_aControlPaths.getLength();
281cdf0e10cSrcweir 		const ::com::sun::star::uno::Sequence<sal_uInt32>* pPaths = m_aControlPaths.getConstArray();
282cdf0e10cSrcweir 		for (sal_Int32 i=0; i<nControls; ++i)
283cdf0e10cSrcweir 		{
284cdf0e10cSrcweir 			sal_Int32 nThisPatLength = pPaths[i].getLength();
285cdf0e10cSrcweir 			const sal_uInt32* pThisPath = pPaths[i].getConstArray();
286cdf0e10cSrcweir 			SvLBoxEntry* pSearch = pRoot;
287cdf0e10cSrcweir 			for (sal_Int32 j=0; j<nThisPatLength; ++j)
288cdf0e10cSrcweir 				pSearch = pTreeBox->GetEntry(pSearch, pThisPath[j]);
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 			m_aSelectedEntries.insert( pSearch );
291cdf0e10cSrcweir 		}
292cdf0e10cSrcweir 	}
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	//====================================================================
295cdf0e10cSrcweir 	//= OControlExchange
296cdf0e10cSrcweir 	//====================================================================
297cdf0e10cSrcweir 	//--------------------------------------------------------------------
OControlExchange()298cdf0e10cSrcweir 	OControlExchange::OControlExchange( )
299cdf0e10cSrcweir 	{
300cdf0e10cSrcweir 	}
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	//--------------------------------------------------------------------
GetData(const DataFlavor & _rFlavor)303cdf0e10cSrcweir 	sal_Bool OControlExchange::GetData( const DataFlavor& _rFlavor )
304cdf0e10cSrcweir 	{
305cdf0e10cSrcweir 		const sal_uInt32 nFormatId = SotExchange::GetFormat( _rFlavor );
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 		if ( getControlPathFormatId( ) == nFormatId )
308cdf0e10cSrcweir 		{
309cdf0e10cSrcweir 			// ugly. We have to pack all the info into one object
310cdf0e10cSrcweir 			Sequence< Any > aCompleteInfo( 2 );
311cdf0e10cSrcweir 			OSL_ENSURE( m_xFormsRoot.is(), "OLocalExchange::GetData: invalid forms root for this format!" );
312cdf0e10cSrcweir 			aCompleteInfo.getArray()[ 0 ] <<= m_xFormsRoot;
313cdf0e10cSrcweir 			aCompleteInfo.getArray()[ 1 ] <<= m_aControlPaths;
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 			SetAny( makeAny( aCompleteInfo ), _rFlavor );
316cdf0e10cSrcweir 		}
317cdf0e10cSrcweir 		else if ( getHiddenControlModelsFormatId() == nFormatId )
318cdf0e10cSrcweir 		{
319cdf0e10cSrcweir 			// just need to transfer the models
320cdf0e10cSrcweir 			SetAny( makeAny( m_aHiddenControlModels ), _rFlavor );
321cdf0e10cSrcweir 		}
322cdf0e10cSrcweir 		else
323cdf0e10cSrcweir 			return OLocalExchange::GetData( _rFlavor );
324cdf0e10cSrcweir 
325cdf0e10cSrcweir 		return sal_True;
326cdf0e10cSrcweir 	}
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 	//--------------------------------------------------------------------
AddSupportedFormats()329cdf0e10cSrcweir 	void OControlExchange::AddSupportedFormats()
330cdf0e10cSrcweir 	{
331cdf0e10cSrcweir 		if (m_pFocusEntry && !m_aSelectedEntries.empty())
332cdf0e10cSrcweir 			AddFormat(getFieldExchangeFormatId());
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 		if (m_aControlPaths.getLength())
335cdf0e10cSrcweir 			AddFormat(getControlPathFormatId());
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 		if (m_aHiddenControlModels.getLength())
338cdf0e10cSrcweir 			AddFormat(getHiddenControlModelsFormatId());
339cdf0e10cSrcweir 	}
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 	//--------------------------------------------------------------------
getControlPathFormatId()342cdf0e10cSrcweir 	sal_uInt32 OControlExchange::getControlPathFormatId()
343cdf0e10cSrcweir 	{
344cdf0e10cSrcweir 		static sal_uInt32 s_nFormat = (sal_uInt32)-1;
345cdf0e10cSrcweir 		if ((sal_uInt32)-1 == s_nFormat)
346cdf0e10cSrcweir 		{
347cdf0e10cSrcweir 			s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"svxform.ControlPathExchange\""));
348cdf0e10cSrcweir 			DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OControlExchange::getControlPathFormatId: bad exchange id!");
349cdf0e10cSrcweir 		}
350cdf0e10cSrcweir 		return s_nFormat;
351cdf0e10cSrcweir 	}
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 	//--------------------------------------------------------------------
getHiddenControlModelsFormatId()354cdf0e10cSrcweir 	sal_uInt32 OControlExchange::getHiddenControlModelsFormatId()
355cdf0e10cSrcweir 	{
356cdf0e10cSrcweir 		static sal_uInt32 s_nFormat = (sal_uInt32)-1;
357cdf0e10cSrcweir 		if ((sal_uInt32)-1 == s_nFormat)
358cdf0e10cSrcweir 		{
359cdf0e10cSrcweir 			s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"svxform.HiddenControlModelsExchange\""));
360cdf0e10cSrcweir 			DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OControlExchange::getHiddenControlModelsFormatId: bad exchange id!");
361cdf0e10cSrcweir 		}
362cdf0e10cSrcweir 		return s_nFormat;
363cdf0e10cSrcweir 	}
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	//--------------------------------------------------------------------
getFieldExchangeFormatId()366cdf0e10cSrcweir 	sal_uInt32 OControlExchange::getFieldExchangeFormatId()
367cdf0e10cSrcweir 	{
368cdf0e10cSrcweir 		static sal_uInt32 s_nFormat = (sal_uInt32)-1;
369cdf0e10cSrcweir 		if ((sal_uInt32)-1 == s_nFormat)
370cdf0e10cSrcweir 		{
371cdf0e10cSrcweir 			s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"svxform.FieldNameExchange\""));
372cdf0e10cSrcweir 			DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OControlExchange::getFieldExchangeFormatId: bad exchange id!");
373cdf0e10cSrcweir 		}
374cdf0e10cSrcweir 		return s_nFormat;
375cdf0e10cSrcweir 	}
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 	//====================================================================
378cdf0e10cSrcweir 	//= OControlExchangeHelper
379cdf0e10cSrcweir 	//====================================================================
createExchange() const380cdf0e10cSrcweir 	OLocalExchange* OControlExchangeHelper::createExchange() const
381cdf0e10cSrcweir 	{
382cdf0e10cSrcweir 		return new OControlExchange;
383cdf0e10cSrcweir 	}
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 	//====================================================================
386cdf0e10cSrcweir 	//= OLocalExchangeHelper
387cdf0e10cSrcweir 	//====================================================================
388cdf0e10cSrcweir 	//--------------------------------------------------------------------
OLocalExchangeHelper(Window * _pDragSource)389cdf0e10cSrcweir 	OLocalExchangeHelper::OLocalExchangeHelper(Window* _pDragSource)
390cdf0e10cSrcweir 		:m_pDragSource(_pDragSource)
391cdf0e10cSrcweir 		,m_pTransferable(NULL)
392cdf0e10cSrcweir 	{
393cdf0e10cSrcweir 	}
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 	//--------------------------------------------------------------------
~OLocalExchangeHelper()396cdf0e10cSrcweir 	OLocalExchangeHelper::~OLocalExchangeHelper()
397cdf0e10cSrcweir 	{
398cdf0e10cSrcweir 		implReset();
399cdf0e10cSrcweir 	}
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 	//--------------------------------------------------------------------
startDrag(sal_Int8 nDragSourceActions)402cdf0e10cSrcweir 	void OLocalExchangeHelper::startDrag( sal_Int8 nDragSourceActions )
403cdf0e10cSrcweir 	{
404cdf0e10cSrcweir 		DBG_ASSERT(m_pTransferable, "OLocalExchangeHelper::startDrag: not prepared!");
405cdf0e10cSrcweir 		m_pTransferable->startDrag( m_pDragSource, nDragSourceActions, OLocalExchange::GrantAccess() );
406cdf0e10cSrcweir 	}
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	//--------------------------------------------------------------------
copyToClipboard() const409cdf0e10cSrcweir 	void OLocalExchangeHelper::copyToClipboard( ) const
410cdf0e10cSrcweir 	{
411cdf0e10cSrcweir 		DBG_ASSERT( m_pTransferable, "OLocalExchangeHelper::copyToClipboard: not prepared!" );
412cdf0e10cSrcweir 		m_pTransferable->copyToClipboard( m_pDragSource, OLocalExchange::GrantAccess() );
413cdf0e10cSrcweir 	}
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 	//--------------------------------------------------------------------
implReset()416cdf0e10cSrcweir 	void OLocalExchangeHelper::implReset()
417cdf0e10cSrcweir 	{
418cdf0e10cSrcweir 		if (m_pTransferable)
419cdf0e10cSrcweir 		{
420cdf0e10cSrcweir 			m_pTransferable->setClipboardListener( Link() );
421cdf0e10cSrcweir 			m_pTransferable->release();
422cdf0e10cSrcweir 			m_pTransferable = NULL;
423cdf0e10cSrcweir 		}
424cdf0e10cSrcweir 	}
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	//--------------------------------------------------------------------
prepareDrag()427cdf0e10cSrcweir 	void OLocalExchangeHelper::prepareDrag( )
428cdf0e10cSrcweir 	{
429cdf0e10cSrcweir 		DBG_ASSERT(!m_pTransferable || !m_pTransferable->isDragging(), "OLocalExchangeHelper::prepareDrag: recursive DnD?");
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 		implReset();
432cdf0e10cSrcweir 		m_pTransferable = createExchange();
433cdf0e10cSrcweir 		m_pTransferable->acquire();
434cdf0e10cSrcweir 	}
435cdf0e10cSrcweir 
436cdf0e10cSrcweir //........................................................................
437cdf0e10cSrcweir }
438cdf0e10cSrcweir //........................................................................
439cdf0e10cSrcweir 
440