update dev300-m58
[ooovba.git] / svx / source / fmcomp / xmlexchg.cxx
blobea13227d5953f5188f450f8e0a913145ef10e7bf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlexchg.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include "xmlexchg.hxx"
34 #include <sot/formats.hxx>
35 #include <sot/exchange.hxx>
36 #include <tools/debug.hxx>
38 //........................................................................
39 namespace svx
41 //........................................................................
43 using namespace ::com::sun::star::datatransfer;
45 //====================================================================
46 //= OXFormsTransferable
47 //====================================================================
48 //--------------------------------------------------------------------
49 OXFormsTransferable::OXFormsTransferable( const OXFormsDescriptor &rhs ) :
50 m_aDescriptor(rhs)
53 //--------------------------------------------------------------------
54 sal_uInt32 OXFormsTransferable::getDescriptorFormatId()
56 static sal_uInt32 s_nFormat = (sal_uInt32)-1;
57 if ((sal_uInt32)-1 == s_nFormat)
59 s_nFormat = SotExchange::RegisterFormatName( String::CreateFromAscii("application/x-openoffice;windows_formatname=\"???\"") );
60 OSL_ENSURE( (sal_uInt32)-1 != s_nFormat, "OXFormsTransferable::getDescriptorFormatId: bad exchange id!" );
62 return s_nFormat;
64 //--------------------------------------------------------------------
65 void OXFormsTransferable::AddSupportedFormats()
67 AddFormat( SOT_FORMATSTR_ID_XFORMS );
69 //--------------------------------------------------------------------
70 sal_Bool OXFormsTransferable::GetData( const DataFlavor& _rFlavor )
72 const sal_uInt32 nFormatId = SotExchange::GetFormat( _rFlavor );
73 if ( SOT_FORMATSTR_ID_XFORMS == nFormatId )
75 return SetString( ::rtl::OUString( String::CreateFromAscii("XForms-Transferable") ), _rFlavor );
77 return sal_False;
79 //--------------------------------------------------------------------
80 const OXFormsDescriptor &OXFormsTransferable::extractDescriptor( const TransferableDataHelper &_rData ) {
82 using namespace ::com::sun::star::uno;
83 using namespace ::com::sun::star::datatransfer;
84 Reference<XTransferable> &transfer = const_cast<Reference<XTransferable> &>(_rData.GetTransferable());
85 XTransferable *pInterface = transfer.get();
86 OXFormsTransferable *pThis = dynamic_cast<OXFormsTransferable *>(pInterface);
87 DBG_ASSERT(pThis,"XTransferable is NOT an OXFormsTransferable???");
88 return pThis->m_aDescriptor;
92 //........................................................................
93 } // namespace svx
94 //........................................................................