xref: /aoo41x/main/svx/source/fmcomp/xmlexchg.cxx (revision f6e50924)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 #include "svx/xmlexchg.hxx"
27 #include <sot/formats.hxx>
28 #include <sot/exchange.hxx>
29 #include <tools/debug.hxx>
30 
31 //........................................................................
32 namespace svx
33 {
34 //........................................................................
35 
36 	using namespace ::com::sun::star::datatransfer;
37 
38 	//====================================================================
39 	//= OXFormsTransferable
40 	//====================================================================
41 	//--------------------------------------------------------------------
OXFormsTransferable(const OXFormsDescriptor & rhs)42 	OXFormsTransferable::OXFormsTransferable( const OXFormsDescriptor &rhs ) :
43 		m_aDescriptor(rhs)
44 	{
45 	}
46 	//--------------------------------------------------------------------
getDescriptorFormatId()47 	sal_uInt32 OXFormsTransferable::getDescriptorFormatId()
48 	{
49 		static sal_uInt32 s_nFormat = (sal_uInt32)-1;
50 		if ((sal_uInt32)-1 == s_nFormat)
51 		{
52 			s_nFormat = SotExchange::RegisterFormatName( String::CreateFromAscii("application/x-openoffice;windows_formatname=\"???\"") );
53 			OSL_ENSURE( (sal_uInt32)-1 != s_nFormat, "OXFormsTransferable::getDescriptorFormatId: bad exchange id!" );
54 		}
55 		return s_nFormat;
56 	}
57 	//--------------------------------------------------------------------
AddSupportedFormats()58 	void OXFormsTransferable::AddSupportedFormats()
59 	{
60 		AddFormat( SOT_FORMATSTR_ID_XFORMS );
61 	}
62 	//--------------------------------------------------------------------
GetData(const DataFlavor & _rFlavor)63 	sal_Bool OXFormsTransferable::GetData( const DataFlavor& _rFlavor )
64 	{
65 		const sal_uInt32 nFormatId = SotExchange::GetFormat( _rFlavor );
66 		if ( SOT_FORMATSTR_ID_XFORMS == nFormatId )
67 		{
68 			return SetString( ::rtl::OUString( String::CreateFromAscii("XForms-Transferable") ), _rFlavor );
69 		}
70 		return sal_False;
71 	}
72 	//--------------------------------------------------------------------
extractDescriptor(const TransferableDataHelper & _rData)73 	const OXFormsDescriptor &OXFormsTransferable::extractDescriptor( const TransferableDataHelper &_rData ) {
74 
75 		using namespace ::com::sun::star::uno;
76 		using namespace ::com::sun::star::datatransfer;
77 		Reference<XTransferable> &transfer = const_cast<Reference<XTransferable> &>(_rData.GetTransferable());
78 		XTransferable *pInterface = transfer.get();
79 		OXFormsTransferable *pThis = dynamic_cast<OXFormsTransferable *>(pInterface);
80 		DBG_ASSERT(pThis,"XTransferable is NOT an OXFormsTransferable???");
81 		return pThis->m_aDescriptor;
82 	}
83 
84 
85 //........................................................................
86 }	// namespace svx
87 //........................................................................
88 
89 
90